summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-10-22 19:21:04 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-10-22 19:21:04 +0200
commit8a3b2f80919eab18567ad526dae84d80032de4f5 (patch)
tree94da0254a8b69b12b22a854a8417b292cc1e30bb
parentd9b075e182b029fd2e18c0edb28a693da9fb2118 (diff)
Check the return value of getnameinfo() on Windows in insp_inet_ntop() and return NULL if it fails
-rw-r--r--win/inspircd_win32wrapper.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index 7707dea0c..d66797f13 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -38,8 +38,8 @@ CoreExport const char *insp_inet_ntop(int af, const void *src, char *dst, sockle
memset(&in, 0, sizeof(in));
in.sin_family = AF_INET;
memcpy(&in.sin_addr, src, sizeof(struct in_addr));
- getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST);
- return dst;
+ if (getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST) == 0)
+ return dst;
}
else if (af == AF_INET6)
{
@@ -47,8 +47,8 @@ CoreExport const char *insp_inet_ntop(int af, const void *src, char *dst, sockle
memset(&in, 0, sizeof(in));
in.sin6_family = AF_INET6;
memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
- getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST);
- return dst;
+ if (getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST) == 0)
+ return dst;
}
return NULL;
}