util: fix possible buffer overflow in util_get_process_exec_path

Found by Coverity.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Fixes: f8f1413070 ("util/u_process: add util_get_process_exec_path")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6067>
(cherry picked from commit f13042ec7e)
This commit is contained in:
Marcin Ślusarz 2020-07-24 18:14:24 +02:00 committed by Eric Engestrom
parent 75e81ff0d7
commit f2de23e785
2 changed files with 4 additions and 1 deletions

View file

@ -1804,7 +1804,7 @@
"description": "util: fix possible buffer overflow in util_get_process_exec_path",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "f8f1413070ae079443ab31a75679cfd10cb756ed"
},

View file

@ -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;