Skip to content

Commit a902365

Browse files
palismfrench
authored andcommitted
cifs: Check for UTF-16 null codepoint in SFU symlink target location
Check that read buffer of SFU symlink target location does not contain UTF-16 null codepoint (via UniStrnlen() call) because Linux cannot process symlink with null byte, it truncates everything in buffer after null byte. Fixes: cf2ce67 ("cifs: Add support for reading SFU symlink location") Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 9852d85 commit a902365

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/smb/client/inode.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,16 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
629629
&symlink_len_utf16,
630630
&symlink_buf_utf16,
631631
&buf_type);
632+
/*
633+
* Check that read buffer has valid length and does not
634+
* contain UTF-16 null codepoint (via UniStrnlen() call)
635+
* because Linux cannot process symlink with null byte.
636+
*/
632637
if ((rc == 0) &&
633638
(symlink_len_utf16 > 0) &&
634639
(symlink_len_utf16 < fattr->cf_eof-8 + 1) &&
635-
(symlink_len_utf16 % 2 == 0)) {
640+
(symlink_len_utf16 % 2 == 0) &&
641+
(UniStrnlen((wchar_t *)symlink_buf_utf16, symlink_len_utf16/2) == symlink_len_utf16/2)) {
636642
fattr->cf_symlink_target =
637643
cifs_strndup_from_utf16(symlink_buf_utf16,
638644
symlink_len_utf16,

0 commit comments

Comments
 (0)