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>
The problem is, that you simply count all lease occurrences in
dhcpd.leases, but only the last ones for each ip address are
valid. The lease file is more like a logfile of what has been
done, than a real database. To fix the counting issue, I'm using
a single hash (from uthash.h [1]) for the counting. This way
only the last lease entry for each IP gets into my counting
structure.
When you remove the duplicates in prepare_data(), you don't have
the information anymore, if the active lease entry or the free
lease entry came last. Simply deleting each ip from the touches
array, that is already in the leases array, gives you a big
chance to count wrong. Another way of fixing this would be to
not only store the ips in your arrays, but a structure containing
the ip and a global lease entry counter. Then you could delete
all entries except for the latest.
[1] http://uthash.sourceforge.net/
Reported-by: Huangy
Signed-off-by: Enno Grper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
[src/getdata.c:307]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:324]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:340]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:362]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:366]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:371]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:372]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:385]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When { is wrote together with a word, such as
pool{
range 10.0.0.100 100.0.0.200;
range ..
the parser ignored first range, resulting it to disappear from analysis.
Reported-by: Robert Viou <robert.viou@ndsu.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The script is not maintained, but perhaps nice to have a
reference how the IP sorting & range matching was done in demo
version. Actually more proper version number would have been 0.x
but it was not.
Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>
This patch adds consistant underlining to arguments, and unifies
spacing. Also the wording for -L is made much better, it's been
common to hear the manual was unclear about that option.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Version 2.16 needs the patche to compile correctly and without
warnings (tested on NetBSD, Mac OS X and Debian/Ubuntu).
Signed-off-by: Adam Ciarcinski <adam@netbsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Version 2.16 needs the patche to compile correctly and without
warnings (tested on NetBSD, Mac OS X and Debian/Ubuntu).
Signed-off-by: Adam Ciarcinski <adam@netbsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
other.c:77:7: warning: ISO C90 does not support the 'z' gnu_printf length modifier [-Wformat]
other.c:169:2: warning: string length '1046' is greater than the length '509' ISO C90 compilers are required to support [-Woverlength-strings]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The strstr is changed to xstrstr, which short cuts to points in
string where first differences are expected to found. This made
the tool tiny bit quicker.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commit 1e82461875 was
incomplete, and at the end was a cause of off by one miscount.
The reason was bsearch where long int needed to be unsigned.
Weird that the original had work while there where so many type
mismatches.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Command version number in manual page output prone to be forgot
at the release time, so it is best to remove it completely.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Add recent changes to autotools header, function and compiler
capability checks. The patch also adds to .gitignore autoscan
outputs.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The full html will now print the mtime of dhcpd.leases file in
header. Additionally at the footer of the page the dhcpd-pools
will have package name and version number.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Remove unnecessary type casting, move .gitignore file contents to
right location, reindent to use Linux coding style, fix few type
mismatches, clean up to help & version output and hint compiler
call to these functions will end program.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
My stupid mistake to leave statement hanging around while I where
wondering where the uninitialized memory came from.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
After uint32_t fix from 1e82461875
it was good idea to check which headers where needed where. And
generally clean up the includes while doing the check.
There where long and unsigned long used for IPs in use which
caused occasional off by one errors. The word occasional should
be read: pretty much every one with large enough configuration
has been affected.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Ahmed reported he saw the following error with version 2.15 which
is an indication of unusual high number of clients that has been
seen. I am not sure where that happen, but I suspect an airport
or some other 'lots of mobiles getting leases' might be able to
case same situation.
dhcpd-pools: getdata.c:136: parse_leases: Assertion `!(touchesmallocsize < num_touches)' failed.
The problem was quite easy to fix simply getting rid of assert
and putting realloc in place.
Reported-by: Ahmed AL Dakhil <a.aldakhil@go.com.sa>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The lack of initialization may have cause unexpected outputs to
some users some times. That sort of behavior is also known by
name a bug.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Usage of includes are set up the way found to be in use, with a help of
magnificent utility.
http://code.google.com/p/include-what-you-use/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>