From 89fc7d80c46154976a0eeb53087f5c9539528c24 Mon Sep 17 00:00:00 2001 From: lilohuang Date: Sun, 3 Aug 2014 16:28:40 +0800 Subject: [PATCH] windows: fix buffer overflow on uv__getnameinfo_work() According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms738531.aspx, "NodeBufferSize" and "ServiceBufferSize" parameters of GetNameInfoW() function are expected to represent the number of WCHAR, not the buffer size of memory layout. --- src/win/getnameinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win/getnameinfo.c b/src/win/getnameinfo.c index b8bf23b8a..45608dae8 100644 --- a/src/win/getnameinfo.c +++ b/src/win/getnameinfo.c @@ -49,9 +49,9 @@ static void uv__getnameinfo_work(struct uv__work* w) { ret = GetNameInfoW((struct sockaddr*)&req->storage, sizeof(req->storage), host, - sizeof(host), + ARRAY_SIZE(host), service, - sizeof(service), + ARRAY_SIZE(service), req->flags); req->retcode = uv__getaddrinfo_translate_error(ret);