From f0e7b2f509d02a1cb259bd1f542d8c1abe86848b Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Mon, 3 Dec 2018 09:07:53 -0800 Subject: [PATCH] src: fix warning for potential snprintf truncation gcc 8+ recognizes that space has not been left for the pid and that the return value of snprintf() isn't checked. Leave a little space for the pid to prevent `-Wformat-truncation`. PR-URL: https://github.com/nodejs/node/pull/24810 Reviewed-By: Richard Lau --- src/util.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util.cc b/src/util.cc index 9f0b8ebc9d7596..ba30b23770b52e 100644 --- a/src/util.cc +++ b/src/util.cc @@ -116,7 +116,8 @@ std::string GetHumanReadableProcessName() { } void GetHumanReadableProcessName(char (*name)[1024]) { - char title[1024] = "Node.js"; + // Leave room after title for pid, which can be up to 20 digits for 64 bit. + char title[1000] = "Node.js"; uv_get_process_title(title, sizeof(title)); snprintf(*name, sizeof(*name), "%s[%d]", title, uv_os_getpid()); }