bcc_procutils_which: return if snprintf fails or would overflow
diff --git a/src/cc/bcc_proc.c b/src/cc/bcc_proc.c
index 5343dbb..b6c6132 100644
--- a/src/cc/bcc_proc.c
+++ b/src/cc/bcc_proc.c
@@ -46,8 +46,10 @@
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);