From: Alok Swaminathan Date: Mon, 26 Aug 2024 15:57:09 +0000 (-0400) Subject: lib: glob.c: added null check for character class X-Git-Tag: v6.12~389^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b0a5b666959719043123a8882bae49ec699d948;p=platform%2Fkernel%2Flinux-amlogic.git lib: glob.c: added null check for character class Add null check for character class. Previously, an inverted character class could result in a nul byte being matched and lead to the function reading past the end of the inputted string. Link: https://lkml.kernel.org/r/20240826155709.12383-1-swaminathanalok@gmail.com Signed-off-by: Alok Swaminathan Signed-off-by: Andrew Morton --- diff --git a/lib/glob.c b/lib/glob.c index 15b73f490720..aa57900d2062 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -68,6 +68,8 @@ bool __pure glob_match(char const *pat, char const *str) back_str = --str; /* Allow zero-length match */ break; case '[': { /* Character class */ + if (c == '\0') /* No possible match */ + return false; bool match = false, inverted = (*pat == '!'); char const *class = pat + inverted; unsigned char a = *class++;