mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 08:16:59 +00:00
getdata: make a lease address detection more robust
The commit 805d353584 did not fix all
possible problem cases. This commit attempts to address remaining
issues.
Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
1a7649beb3
commit
b24fc42ec8
1 changed files with 13 additions and 2 deletions
15
src/other.c
15
src/other.c
|
|
@ -40,6 +40,7 @@
|
|||
#include <config.h>
|
||||
|
||||
#include "dhcpd-pools.h"
|
||||
#include "defaults.h"
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -160,10 +161,20 @@ int
|
|||
xstrstr(const char *restrict a, const char *restrict b, const int len)
|
||||
{
|
||||
int i;
|
||||
/* Skip when config.dhcp_version == VERSION_UNKNOWN -> len is zero. */
|
||||
if (len == 0) {
|
||||
|
||||
/* Needed when dhcpd.conf has zero range definitions. */
|
||||
if (config.dhcp_version == VERSION_UNKNOWN) {
|
||||
if (!strcmp(prefixes[VERSION_4][PREFIX_LEASE], a)) {
|
||||
config.dhcp_version = VERSION_4;
|
||||
return true;
|
||||
}
|
||||
if (!strcmp(prefixes[VERSION_6][PREFIX_LEASE], a)) {
|
||||
config.dhcp_version = VERSION_6;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* two spaces are very common in lease file, after them
|
||||
* nearly everything differs */
|
||||
if (likely(a[2] != b[2])) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue