From: Mark Wielaard Date: Sat, 4 Dec 2021 12:07:04 +0000 (+0100) Subject: debuginfod: sqlite3_sharedprefix_fn should not compare past end of string X-Git-Tag: elfutils-0.187~81 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32ceb411faec6ca61ee04707fe014efa15e9a5df;p=thirdparty%2Felfutils.git debuginfod: sqlite3_sharedprefix_fn should not compare past end of string gcc address sanitizer detected a read after the end of string in sqlite3_sharedprefix_fn. Make sure to stop comparing the strings when seeing the zero terminator. Signed-off-by: Mark Wielaard --- diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 0bbaae9fd..0d3f02978 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -3707,7 +3707,7 @@ static void sqlite3_sharedprefix_fn (sqlite3_context* c, int argc, sqlite3_value const unsigned char* a = sqlite3_value_text (argv[0]); const unsigned char* b = sqlite3_value_text (argv[1]); int i = 0; - while (*a++ == *b++) + while (*a != '\0' && *b != '\0' && *a++ == *b++) i++; sqlite3_result_int (c, i); }