Commit 5a7882e3 authored by Christian Resell's avatar Christian Resell Committed by Brenden Blanco

bcc_procutils_which: return if snprintf fails or would overflow

parent c6c9f0a3
......@@ -46,8 +46,10 @@ char *bcc_procutils_which(const char *binpath) {
const size_t path_len = next - PATH;
if (path_len) {
snprintf(buffer, sizeof(buffer), "%.*s/%s",
(int)path_len, PATH, binpath);
int ret = snprintf(buffer, sizeof(buffer), "%.*s/%s",
(int)path_len, PATH, binpath);
if (ret < 0 || ret >= sizeof(buffer))
return 0;
if (bcc_elf_is_exe(buffer))
return strdup(buffer);
......
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