analyze: a lot of IP counts being missed

Fix to a very severe bug.  In cases when IP addresses in lease file had
a range of using highest bit, e.g.  signed int minus, the sort caused
high ranges to be counted first and low ranges skipped.  The usual case
when this happen was when ranges contained 10.0.0.0/8 addresses
together with addresses greater than 128.0.0.0/32.

Reported-by: Ryan Malek <rmalek@osage.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-06-13 21:36:37 +02:00
parent 3c9226752b
commit 8f3d8ceae7

View file

@ -44,7 +44,11 @@
/* Clean up data */ /* Clean up data */
int ip_sort(struct leases_t *a, struct leases_t *b) int ip_sort(struct leases_t *a, struct leases_t *b)
{ {
return (a->ip - b->ip); if (a->ip < b->ip)
return -1;
if (a->ip > b->ip)
return 1;
return 0;
} }
int prepare_data(void) int prepare_data(void)