Skip to contentSkip to conversation

cifs: fix an OOB issue in cifsConvertToUTF16()

PATCH New Ding Hui 1 participant 1 message Jul 6, 2025 SMB client (CIFS)

lore
Share & tools
lore

Ding Hui

author
#0 lore raw

PATCH 1/1 cifs: fix an OOB issue in cifsConvertToUTF16()

The OOB can be triggered by making symlink in reparse=native mode.

Limit the srclen can not greater than maxlen.

Fixes 2503a0dba989 ("CIFS: Add SMB2 support for is_path_accessible")
---
 fs/smb/client/cifs_unicode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifs_unicode.c +1 -1
index 4cc6e0896fad..cee43e71fa87 100644
@@ -636,7 +636,7 @@ cifs_strndup_to_utf16(const char *src, const int maxlen, int *utf16_len,
 		*utf16_len = 0;
 		return NULL;
 	}
-	cifsConvertToUTF16(dst, src, strlen(src), cp, remap);
+	cifsConvertToUTF16(dst, src, strnlen(src, maxlen), cp, remap);
 	*utf16_len = len;
 	return dst;
 }
Signature · 1 line
2.17.1