Skip to content

Commit

Permalink
add sanity check for theoretical unsigned integer overflow in daemon …
Browse files Browse the repository at this point in the history
…interface removal handling, fix testcase lacking correct interface count initialization, improve error message placement in image output
  • Loading branch information
vergoh committed Jan 18, 2020
1 parent 8e9eeca commit 21acf67
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,9 @@ void cleanremovedinterfaces(DSTATE *s)
snprintf(errorstring, 1024, "Removing interface \"%s\" from update list.", dbifl_iterator->interface);
printe(PT_Info);
datacache_remove(&s->dcache, dbifl_iterator->interface);
s->dbifcount--;
if (s->dbifcount > 0) {
s->dbifcount--;
}
dbifl_iterator = dbifl_iterator->next;
}
datacache_status(&s->dcache);
Expand Down
2 changes: 1 addition & 1 deletion src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ int drawhours(IMAGECONTENT *ic, const int x, const int y, const int rate)
}

if (datainfo.count == 0) {
gdImageString(ic->im, gdFontGetSmall(), 200, 100, (unsigned char *)"no data available", ic->ctext);
gdImageString(ic->im, gdFontGetSmall(), x + 188, y + 54, (unsigned char *)"no data available", ic->ctext);
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions tests/daemon_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ START_TEST(processdatacache_can_process_things)
s.bootdetected = 1;
s.dodbsave = 1;
s.cleanuphour = getcurrenthour() + 1;
s.dbifcount = 3;

ck_assert_int_eq(datacache_count(&s.dcache), 0);
ret = datacache_add(&s.dcache, "ethnotindb", 0);
Expand Down

0 comments on commit 21acf67

Please sign in to comment.