From f2756500ed8fc14ba11cf5bf0a3cee6f3b66eecb Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 25 May 2017 08:58:24 +0200 Subject: [PATCH] unix: avoid segfault in uv_get_process_title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/libuv/libuv/issues/1359 PR-URL: https://github.com/libuv/libuv/pull/1360 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Saúl Ibarra Corretgé --- src/unix/proctitle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/proctitle.c b/src/unix/proctitle.c index 9160f7ea..2ed0b21c 100644 --- a/src/unix/proctitle.c +++ b/src/unix/proctitle.c @@ -98,7 +98,9 @@ int uv_get_process_title(char* buffer, size_t size) { else if (size <= process_title.len) return -ENOBUFS; - memcpy(buffer, process_title.str, process_title.len + 1); + if (process_title.len != 0) + memcpy(buffer, process_title.str, process_title.len + 1); + buffer[process_title.len] = '\0'; return 0;