Skip to contentSkip to conversation

btrfs: Do not return more items that user asked from from search ioctl

PATCH New Jan Kara 1 participant 1 message Aug 20, 2010 Btrfs file system

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 btrfs: Do not return more items that user asked from from search ioctl

While searching a tree we didn't properly check number of items we really stored in user's buffer thus possibly exceeding number of items requested by user. This was mostly harmless since actual buffer overflow is checked correctly in a different place. Anyway, let's fix the check.

---
 fs/btrfs/ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/btrfs/ioctl.c +1 -1
index 9254b3d..94e7ab5 100644
@@ -977,7 +977,7 @@ static noinline int copy_to_sk(struct btrfs_root *root,
 		}
 		found++;
 
-		if (*num_found >= sk->nr_items)
+		if (*num_found + found >= sk->nr_items)
 			break;
 	}
 advance_key:
Signature · 1 line
1.6.4.2