summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2018-12-03 09:07:53 -0800
committerSam Roberts <vieuxtech@gmail.com>2018-12-07 10:13:44 -0800
commita9a595657651cd5c66a1d0ee8749ace8fb6b51c3 (patch)
treebbe03151ee6b9642c9f386bf95f03d06a7ec272a /src
parentbcef949c931f54e3d8ae2a1701f2538262e6bec9 (diff)
downloadandroid-node-v8-a9a595657651cd5c66a1d0ee8749ace8fb6b51c3.tar.gz
android-node-v8-a9a595657651cd5c66a1d0ee8749ace8fb6b51c3.tar.bz2
android-node-v8-a9a595657651cd5c66a1d0ee8749ace8fb6b51c3.zip
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 <riclau@uk.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/util.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/util.cc b/src/util.cc
index 9f0b8ebc9d..ba30b23770 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());
}