Skip to content

Commit 94d02ca

Browse files
sam-githubMylesBorins
authored andcommitted
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: #24810 Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent c3dda00 commit 94d02ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/util.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ std::string GetHumanReadableProcessName() {
116116
}
117117

118118
void GetHumanReadableProcessName(char (*name)[1024]) {
119-
char title[1024] = "Node.js";
119+
// Leave room after title for pid, which can be up to 20 digits for 64 bit.
120+
char title[1000] = "Node.js";
120121
uv_get_process_title(title, sizeof(title));
121122
snprintf(*name, sizeof(*name), "%s[%d]", title, uv_os_getpid());
122123
}

0 commit comments

Comments
 (0)