Skip to content

Commit 78ec5bf

Browse files
Fredric Coversmfrench
authored andcommitted
fs/smb/client: fix out-of-bounds read in cifs_sanitize_prepath
When cifs_sanitize_prepath is called with an empty string or a string containing only delimiters (e.g., "/"), the current logic attempts to check *(cursor2 - 1) before cursor2 has advanced. This results in an out-of-bounds read. This patch adds an early exit check after stripping prepended delimiters. If no path content remains, the function returns NULL. The bug was identified via manual audit and verified using a standalone test case compiled with AddressSanitizer, which triggered a SEGV on affected inputs. Signed-off-by: Fredric Cover <[email protected]> Reviewed-by: Henrique Carvalho <[2][email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 7aaa804 commit 78ec5bf

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fs/smb/client/fs_context.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ char *cifs_sanitize_prepath(char *prepath, gfp_t gfp)
588588
while (IS_DELIM(*cursor1))
589589
cursor1++;
590590

591+
/* exit in case of only delimiters */
592+
if (!*cursor1)
593+
return NULL;
594+
591595
/* copy the first letter */
592596
*cursor2 = *cursor1;
593597

0 commit comments

Comments
 (0)