Skip to content

Commit 592c64f

Browse files
kdaveadam900710
authored andcommitted
btrfs-progs: use safer allocation in get_fs_info()
Let's use calloc() as it handles the potential argument multiplication overflow. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 13f3efa commit 592c64f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

common/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
225225
if (!fi_args->num_devices)
226226
goto out;
227227

228-
di_args = *di_ret = malloc((fi_args->num_devices) * sizeof(*di_args));
228+
di_args = *di_ret = calloc(fi_args->num_devices, sizeof(*di_args));
229229
if (!di_args) {
230230
ret = -errno;
231231
goto out;

0 commit comments

Comments
 (0)