nfqws: fixed lists

This commit is contained in:
bol-van
2024-11-24 16:48:14 +03:00
parent f00b45a28e
commit a623cef95d
6 changed files with 293 additions and 108 deletions

View File

@@ -160,12 +160,17 @@ struct hostlist_file *hostlist_files_add(struct hostlist_files_head *head, const
struct hostlist_file *entry = malloc(sizeof(struct hostlist_file));
if (entry)
{
if (!(entry->filename = strdup(filename)))
if (filename)
{
free(entry);
return false;
if (!(entry->filename = strdup(filename)))
{
free(entry);
return false;
}
}
entry->mod_time=0;
else
entry->filename = NULL;
entry->mod_time = 0;
entry->hostlist = NULL;
LIST_INSERT_HEAD(head, entry, next);
}
@@ -192,7 +197,7 @@ struct hostlist_file *hostlist_files_search(struct hostlist_files_head *head, co
LIST_FOREACH(hfile, head, next)
{
if (!strcmp(hfile->filename,filename))
if (hfile->filename && !strcmp(hfile->filename,filename))
return hfile;
}
return NULL;
@@ -223,7 +228,7 @@ struct hostlist_item *hostlist_collection_search(struct hostlist_collection_head
LIST_FOREACH(item, head, next)
{
if (!strcmp(item->hfile->filename,filename))
if (item->hfile->filename && !strcmp(item->hfile->filename,filename))
return item;
}
return NULL;
@@ -369,12 +374,17 @@ struct ipset_file *ipset_files_add(struct ipset_files_head *head, const char *fi
struct ipset_file *entry = malloc(sizeof(struct ipset_file));
if (entry)
{
if (!(entry->filename = strdup(filename)))
if (filename)
{
free(entry);
return false;
if (!(entry->filename = strdup(filename)))
{
free(entry);
return false;
}
}
entry->mod_time=0;
else
entry->filename = NULL;
entry->mod_time = 0;
memset(&entry->ipset,0,sizeof(entry->ipset));
LIST_INSERT_HEAD(head, entry, next);
}
@@ -401,7 +411,7 @@ struct ipset_file *ipset_files_search(struct ipset_files_head *head, const char
LIST_FOREACH(hfile, head, next)
{
if (!strcmp(hfile->filename,filename))
if (hfile->filename && !strcmp(hfile->filename,filename))
return hfile;
}
return NULL;
@@ -432,7 +442,7 @@ struct ipset_item *ipset_collection_search(struct ipset_collection_head *head, c
LIST_FOREACH(item, head, next)
{
if (!strcmp(item->hfile->filename,filename))
if (item->hfile->filename && !strcmp(item->hfile->filename,filename))
return item;
}
return NULL;