Commit e9fa4521 authored by Sébastien Gonzalve's avatar Sébastien Gonzalve Committed by Arjan Spieard

Fix off by one in readlink

parent b357bed9
......@@ -2,9 +2,8 @@
fs::path execname() {
char buf[1024];
ssize_t maxchars = sizeof(buf) - 1;
ssize_t size = readlink("/proc/self/exe", buf, sizeof(buf));
if (size <= 0 || size >= maxchars) return fs::path();
ssize_t size = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
if (size < 0) return fs::path();
buf[size] = '\0';
return buf;
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment