From: Victor Julien Date: Mon, 11 Dec 2017 17:18:28 +0000 (+0100) Subject: mingw: improve ipaddress parsing X-Git-Tag: suricata-4.1.0-beta1~387 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ddf48899fad28bd21f7f187c0eb305ae105b8a;p=thirdparty%2Fsuricata.git mingw: improve ipaddress parsing --- diff --git a/src/win32-misc.c b/src/win32-misc.c index 80eb29cd62..ed52eb5b7a 100644 --- a/src/win32-misc.c +++ b/src/win32-misc.c @@ -28,6 +28,7 @@ #include "suricata-common.h" #include "win32-misc.h" #include "direct.h" +#include "util-ip.h" void setenv(const char *name, const char *value, int overwrite) { @@ -80,6 +81,17 @@ int inet_pton(int af, const char *src, void *dst) memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = af; + /* as getaddrinfo below seems more liberal that inet_pton on Linux, + * add this check here that does a guess at the validity of the + * input address. */ + if (af == AF_INET) { + if (!IPv4AddressStringIsValid(src)) + return -1; + } else if (af == AF_INET6) { + if (!IPv6AddressStringIsValid(src)) + return -1; + } + struct addrinfo* result = NULL; if (0 != getaddrinfo(src, NULL, &hints, &result)) return -1;