Skip to contentSkip to conversation

fat: Read buffer overflow

PATCH Alexander Koeppe 1 participant 1 message Aug 8, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 19 lines · Roel Kluin

If len is less or equal to 0, this results in a read of s[-1].

---

fs/fat/namei_vfat.c +3 -1
index 6f27853..114ff6d 100644
@@ -202,6 +202,9 @@ static inline int vfat_is_used_badchars(const wchar_t *s, int len)
 {
 	int i;
 
+	if (len <= 0)
+		return -EINVAL;
+
 	for (i = 0; i < len; i++)
 		if (vfat_bad_char(s[i]))
 			return -EINVAL;
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This seem to be a bit redundant code.
If len is 0 or less, the loop won't iterate even one time and hence not read outside the buffer.
The only advantage is, that re function signals the invalid argument.

-- A.Koeppe