diff --git a/src/unix/sunos.c b/src/unix/sunos.c index 04a8cb49..ca183a62 100644 --- a/src/unix/sunos.c +++ b/src/unix/sunos.c @@ -304,7 +304,11 @@ int uv_exepath(char* buffer, size_t* size) { return -EINVAL; snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid()); - res = readlink(buf, buffer, *size - 1); + + res = *size - 1; + if (res > 0) + res = readlink(buf, buffer, res); + if (res == -1) return -errno;