mirror of
https://github.com/ValdikSS/GoodbyeDPI.git
synced 2024-12-22 22:35:58 +00:00
Malloc return value check
This commit is contained in:
parent
62f2953515
commit
420dad3bcd
@ -36,6 +36,10 @@ static int add_hostname(const char *host) {
|
||||
return FALSE;
|
||||
|
||||
blackwhitelist_record_t *tmp_record = malloc(sizeof(blackwhitelist_record_t));
|
||||
|
||||
if (!tmp_record)
|
||||
return FALSE;
|
||||
|
||||
char *host_c = NULL;
|
||||
|
||||
if (!check_get_hostname(host)) {
|
||||
@ -55,6 +59,10 @@ static int add_hostname(const char *host) {
|
||||
|
||||
int blackwhitelist_load_list(const char *filename) {
|
||||
char *line = malloc(HOST_MAXLEN + 1);
|
||||
|
||||
if (!line)
|
||||
return FALSE;
|
||||
|
||||
size_t linelen = HOST_MAXLEN + 1;
|
||||
int cnt = 0;
|
||||
ssize_t read;
|
||||
|
@ -142,6 +142,10 @@ static int add_udp_conntrack(const uint32_t srcip[4], const uint16_t srcport,
|
||||
return FALSE;
|
||||
|
||||
udp_connrecord_t *tmp_connrecord = malloc(sizeof(udp_connrecord_t));
|
||||
|
||||
if (!tmp_connrecord)
|
||||
return FALSE;
|
||||
|
||||
construct_key(srcip, srcport, tmp_connrecord->key, is_ipv6);
|
||||
|
||||
if (!check_get_udp_conntrack_key(tmp_connrecord->key, NULL)) {
|
||||
|
@ -206,6 +206,9 @@ static void add_filter_str(int proto, int port) {
|
||||
(proto == IPPROTO_UDP ? strlen(udp) : strlen(tcp)) + 16;
|
||||
char *new_filter = malloc(new_filter_size);
|
||||
|
||||
if (!new_filter)
|
||||
return FALSE;
|
||||
|
||||
strcpy(new_filter, current_filter);
|
||||
if (proto == IPPROTO_UDP)
|
||||
sprintf(new_filter + strlen(new_filter), udp, port, port);
|
||||
@ -221,6 +224,9 @@ static void add_ip_id_str(int id) {
|
||||
const char *ipid = " or ip.Id == %d";
|
||||
char *addfilter = malloc(strlen(ipid) + 16);
|
||||
|
||||
if (!addfilter)
|
||||
return FALSE;
|
||||
|
||||
sprintf(addfilter, ipid, id);
|
||||
|
||||
newstr = repl_str(filter_string, IPID_TEMPLATE, addfilter);
|
||||
@ -241,6 +247,9 @@ static void add_maxpayloadsize_str(unsigned short maxpayload) {
|
||||
"or (tcp.Payload[0] == 0x16 and tcp.Payload[1] == 0x03 and tcp.Payload[2] <= 0x03): true)";
|
||||
char *addfilter = malloc(strlen(maxpayloadsize_str) + 16);
|
||||
|
||||
if (!addfilter)
|
||||
return FALSE;
|
||||
|
||||
sprintf(addfilter, maxpayloadsize_str, maxpayload);
|
||||
|
||||
newstr = repl_str(filter_string, MAXPAYLOADSIZE_TEMPLATE, addfilter);
|
||||
|
@ -146,6 +146,10 @@ static int add_tcp_conntrack(const uint32_t srcip[4], const uint32_t dstip[4],
|
||||
return FALSE;
|
||||
|
||||
tcp_connrecord_t *tmp_connrecord = malloc(sizeof(tcp_connrecord_t));
|
||||
|
||||
if (!tmp_connrecord)
|
||||
return FALSE;
|
||||
|
||||
construct_key(srcip, dstip, srcport, dstport, tmp_connrecord->key, is_ipv6);
|
||||
|
||||
if (!check_get_tcp_conntrack_key(tmp_connrecord->key, NULL)) {
|
||||
|
Loading…
Reference in New Issue
Block a user