btrfs-progs: don't overrun name in find-collisions

find_collision() allocates name_len bytes for its sub array so the index
must be less than name_len.  This was found by static analysis.

Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
Zach Brown 2013-10-07 14:42:56 -07:00 committed by Chris Mason
parent 91f5f22d7d
commit 961eaa7d39
1 changed files with 2 additions and 2 deletions

View File

@ -314,11 +314,11 @@ static char *find_collision(struct metadump_struct *md, char *name,
if (val->sub[i] == 127) {
do {
i++;
if (i > name_len)
if (i >= name_len)
break;
} while (val->sub[i] == 127);
if (i > name_len)
if (i >= name_len)
break;
val->sub[i]++;
if (val->sub[i] == '/')