From cc91989cc275535400515ff899cc2a75e5d17cbf Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 6 Sep 2011 15:44:47 +0200 Subject: [PATCH] unix: fix buffer overrun in uv__strlcpy() Reported by Thomas Shinnick. --- src/unix/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index 4d713c295..45fef16b6 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -764,10 +764,8 @@ size_t uv__strlcpy(char* dst, const char* src, size_t size) { } org = src; - while (size > 1) { - if ((*dst++ = *src++) == '\0') { - return org - src; - } + while (--size && *src) { + *dst++ = *src++; } *dst = '\0';