Skip to content
Snippets Groups Projects
Commit 3f24e009 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix new potential NULL derefs (the add/del_area args can be NULL)

... in area manager code modified in previous commit.
parent d256c540
No related branches found
No related tags found
No related merge requests found
......@@ -1590,7 +1590,11 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
unsigned j;
faddr_t addr = nodecfg->addr;
const char* addr_str = smb_faddrtoa(&addr,NULL);
size_t add_count;
size_t del_count;
add_count = strListCount(add_area);
del_count = strListCount(del_area);
str_list_t ini = iniReadFile(afilein);
str_list_t areas = iniGetSectionList(ini, /* prefix: */NULL);
fclose(afilein);
......@@ -1601,7 +1605,7 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
/* Don't allow down-links to our "Unknown area" */
continue;
}
if(del_area[0] != NULL) { /* Check for areas to remove */
if(del_count) { /* Check for areas to remove */
bool disconnect_all = (stricmp(del_area[0], "-ALL") == 0);
if(disconnect_all || strListFind(del_area, echotag, /* case-sensitive */false) >= 0) {
uint areanum = find_area(echotag);
......@@ -1629,7 +1633,7 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
continue;
}
}
if(add_area[0] != NULL) { /* Check for areas to add */
if(add_count) { /* Check for areas to add */
bool add_all = (stricmp(add_area[0], "+ALL") == 0);
j = strListFind(add_area, echotag, /* case-sensitive */false);
if(add_all || j >= 0) {
......@@ -1672,7 +1676,7 @@ void alter_areas_ini(FILE* afilein, FILE* afileout, FILE* nmfile
strListWriteFile(afileout, ini, "\n");
strListFree(&ini);
strListFree(&areas);
if(nomatch || (add_area[0] != NULL && stricmp(add_area[0],"+ALL") == 0))
if(nomatch || (add_count && stricmp(add_area[0],"+ALL") == 0))
add_areas_from_echolists(afileout, nmfile, add_area, added, nodecfg);
}
......@@ -1820,7 +1824,7 @@ void alter_areas_bbs(FILE* afilein, FILE* afileout, FILE* nmfile
fprintf(afileout,"%s\n",fields); /* No match so write back line */
}
fclose(afilein);
if(nomatch || (add_area[0] != NULL && stricmp(add_area[0],"+ALL") == 0))
if(nomatch || (add_count && stricmp(add_area[0],"+ALL") == 0))
add_areas_from_echolists(afileout, nmfile, add_area, added, nodecfg);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment