Skip to content

Commit b571e81

Browse files
committed
btrfs-progs: handle readdir() end in get_first_device_zone_size()
readdir() could potentially return NULL in case there's no device in the directory, which is unlikely but should be handled. Reported by CodeQL scan. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent cf98ee7 commit b571e81

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmds/filesystem-usage.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ static u64 get_first_device_zone_size(int fd)
417417
}
418418
while (1) {
419419
de = readdir(dir);
420+
if (!de)
421+
break;
420422
if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0)
421423
continue;
422424
strcpy(name, de->d_name);

0 commit comments

Comments
 (0)