提交 2e97c389 编写于 作者: N Nik Bougalis

Avoid off-by-one error when using readlink

上级 40ddc3d6
...@@ -33,7 +33,7 @@ const char* GetExecutableName() { ...@@ -33,7 +33,7 @@ const char* GetExecutableName() {
char link[1024]; char link[1024];
snprintf(link, sizeof(link), "/proc/%d/exe", getpid()); snprintf(link, sizeof(link), "/proc/%d/exe", getpid());
auto read = readlink(link, name, sizeof(name)); auto read = readlink(link, name, sizeof(name) - 1);
if (-1 == read) { if (-1 == read) {
return nullptr; return nullptr;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册