Skip to content

Commit

Permalink
src: fix warning for potential snprintf truncation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sam-github authored and MylesBorins committed Dec 7, 2018
1 parent c3dda00 commit 94d02ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 94d02ca

Please sign in to comment.