mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 01:05:29 +00:00
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 <swaminathanalok@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
74b0099340
commit
7b0a5b6669
@ -68,6 +68,8 @@ bool __pure glob_match(char const *pat, char const *str)
|
|||||||
back_str = --str; /* Allow zero-length match */
|
back_str = --str; /* Allow zero-length match */
|
||||||
break;
|
break;
|
||||||
case '[': { /* Character class */
|
case '[': { /* Character class */
|
||||||
|
if (c == '\0') /* No possible match */
|
||||||
|
return false;
|
||||||
bool match = false, inverted = (*pat == '!');
|
bool match = false, inverted = (*pat == '!');
|
||||||
char const *class = pat + inverted;
|
char const *class = pat + inverted;
|
||||||
unsigned char a = *class++;
|
unsigned char a = *class++;
|
||||||
|
Loading…
Reference in New Issue
Block a user