Skip to contentSkip to conversation

fs/fat: fix ENOSPC condition of directory entries.

PATCH NAK NODA, Kai 2 participants 3 messages Dec 23, 2013

Subsystems (2)
lore
Share & tools
lore

NODA, Kai

author
#0 lore raw

PATCH 1/1 fs/fat: fix ENOSPC condition of directory entries.

From: "NODA, Kai" <[email protected]>

FAT_MAX_DIR_ENTRIES entries in a normal directory should be permitted as per the FAT spec. Previously the max number of entries was FAT_MAX_DIR_ENTRIES - 1 due to the bug.

---
 fs/fat/dir.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/dir.c +1 -1
index 3963ede..cf9be44 100644
@@ -1288,7 +1288,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
 	err = -ENOSPC;
 	while (fat_get_entry(dir, &pos, &bh, &de) > -1) {
 		/* check the maximum size of directory */
-		if (pos >= FAT_MAX_DIR_SIZE)
+		if (pos > FAT_MAX_DIR_SIZE)
 			goto error;
 
 		if (IS_FREE(de->name)) {
Signature · 1 line
1.7.9.5
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Kai

From: "NODA, Kai" <[email protected]>

FAT_MAX_DIR_ENTRIES entries in a normal directory should be permitted as per the FAT spec. Previously the max number of entries was FAT_MAX_DIR_ENTRIES - 1 due to the bug.

Looks good.

Thanks.

Quoted 17 lines
---
 fs/fat/dir.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/dir.c +1 -1
index 3963ede..cf9be44 100644
@@ -1288,7 +1288,7 @@ int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
 	err = -ENOSPC;
 	while (fat_get_entry(dir, &pos, &bh, &de) > -1) {
 		/* check the maximum size of directory */
-		if (pos >= FAT_MAX_DIR_SIZE)
+		if (pos > FAT_MAX_DIR_SIZE)
 			goto error;
 
 		if (IS_FREE(de->name)) {
Signature · 1 line
OGAWA Hirofumi <[email protected]>
maintainer NAK
#2 lore raw
Quoted 8 lines · OGAWA Hirofumi
Quoted 6 lines · Kai

From: "NODA, Kai" <[email protected]>

FAT_MAX_DIR_ENTRIES entries in a normal directory should be permitted as per the FAT spec. Previously the max number of entries was FAT_MAX_DIR_ENTRIES - 1 due to the bug.

Quoted 5 lines
Quoted 1 line

Looks good.

NAK, after re-read.

Actually, this was wrong fix. After read last entry of block, fat_get_entry() returns -1. So, pos is not checked. In short, this allows FAT_MAX_DIR_ENTRIES+1, not FAT_MAX_DIR_ENTRIES, right?

Please fix the patch, and really test it.

Signature · 1 line
OGAWA Hirofumi <[email protected]>