Skip to content

Commit

Permalink
lib: glob.c: added null check for character class
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
AlokSwaminathan authored and akpm00 committed Sep 9, 2024
1 parent 74b0099 commit 7b0a5b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 7b0a5b6

Please sign in to comment.