getdata: certain input files caused SIGSEGV

When dhcpd.conf file got to be parsed such way that IP version could not
be determined the dhcpd.lease file parsing resulted to SIGSEGV.

Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-04-21 14:30:21 +01:00
parent 5966360f12
commit 805d353584
2 changed files with 5 additions and 0 deletions

1
THANKS
View file

@ -26,3 +26,4 @@ Ryan Malek
Cheer Xiao Cheer Xiao
Gilles Bouthenot Gilles Bouthenot
Helmut Grohne Helmut Grohne
Joey D.

View file

@ -160,6 +160,10 @@ int
xstrstr(const char *restrict a, const char *restrict b, const int len) xstrstr(const char *restrict a, const char *restrict b, const int len)
{ {
int i; int i;
/* Skip when config.dhcp_version == VERSION_UNKNOWN -> len is zero. */
if (len == 0) {
return false;
}
/* two spaces are very common in lease file, after them /* two spaces are very common in lease file, after them
* nearly everything differs */ * nearly everything differs */
if (likely(a[2] != b[2])) { if (likely(a[2] != b[2])) {