From 9d44f8945802406390b2a33fb9271e96dd2be341 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Mon, 19 Aug 2019 13:57:51 +0100 Subject: [PATCH] runtime: Fix buffer underrun if version.txt is empty Detected by AddressSanitizer (meson -Dsanitize=address,undefined). Signed-off-by: Simon McVittie <smcv@collabora.com> --- steam-runtime-tools/runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steam-runtime-tools/runtime.c b/steam-runtime-tools/runtime.c index 324ae7e2f..d690d0601 100644 --- a/steam-runtime-tools/runtime.c +++ b/steam-runtime-tools/runtime.c @@ -234,7 +234,7 @@ _srt_runtime_check (const char *bin32, const char *underscore = strrchr (contents, '_'); /* Remove trailing \n if any */ - if (contents[len - 1] == '\n') + if (len > 0 && contents[len - 1] == '\n') contents[--len] = '\0'; if (len != strlen (contents) || -- GitLab