From f13042ec7ea6842cbee81590f40b0e5c2e25a9bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marcin=20=C5=9Alusarz?= Date: Fri, 24 Jul 2020 18:14:24 +0200 Subject: [PATCH] util: fix possible buffer overflow in util_get_process_exec_path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Found by Coverity. Signed-off-by: Marcin Ślusarz Fixes: f8f1413070a ("util/u_process: add util_get_process_exec_path") Reviewed-by: Marek Olšák Part-of: --- src/util/u_process.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/u_process.c b/src/util/u_process.c index 74c4d10192e..68fda93a53b 100644 --- a/src/util/u_process.c +++ b/src/util/u_process.c @@ -187,6 +187,9 @@ util_get_process_exec_path(char* process_path, size_t len) return 0; success: + if (r == len) + return 0; + process_path[r] = '\0'; return r; -- 2.30.2