mingw: improve ipaddress parsing

pull/3112/head
Victor Julien 8 years ago
parent d62a212fa2
commit 28ddf48899

@ -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;

Loading…
Cancel
Save