Skip to content

Commit 7b0a5b6

Browse files
AlokSwaminathanakpm00
authored andcommitted
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/[email protected] Signed-off-by: Alok Swaminathan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 74b0099 commit 7b0a5b6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/glob.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ bool __pure glob_match(char const *pat, char const *str)
6868
back_str = --str; /* Allow zero-length match */
6969
break;
7070
case '[': { /* Character class */
71+
if (c == '\0') /* No possible match */
72+
return false;
7173
bool match = false, inverted = (*pat == '!');
7274
char const *class = pat + inverted;
7375
unsigned char a = *class++;

0 commit comments

Comments
 (0)