From 385b7960a056686e6d7326b4ebe26b922619b36d Mon Sep 17 00:00:00 2001 From: twosee Date: Thu, 27 May 2021 22:54:33 +0800 Subject: [PATCH] inet: fix inconsistent return value of inet_ntop6 PR-URL: https://github.com/libuv/libuv/pull/3182 Reviewed-By: Jameson Nash --- src/inet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/inet.c b/src/inet.c index 698ab232..ddabf22f 100644 --- a/src/inet.c +++ b/src/inet.c @@ -141,8 +141,9 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) { if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words)) *tp++ = ':'; *tp++ = '\0'; - if (UV_E2BIG == uv__strscpy(dst, tmp, size)) + if ((size_t) (tp - tmp) > size) return UV_ENOSPC; + uv__strscpy(dst, tmp, size); return 0; }