btrfs-progs: cmd-subvolume: set subvol_path to NULL after free
PATCH 1/1 btrfs-progs: cmd-subvolume: set subvol_path to NULL after free
User reported that btrfs subvolume show -u -- /mnt causes double free.
Pointer subovl_path was freed in iterations but still keeps old value. In the last iteration, error BTRFS_UTIL_ERROR_STOP_ITERATION returned, then the double free of subvol_path happens in the out goto label.
Set subvol_path to NULL after each free() in the loop to fix the issue.
Links: https://github.com/kdave/btrfs-progs/issues/317
--- cmds/subvolume.c | 1 + 1 file changed, 1 insertion(+)
cmds/subvolume.c +1 -0
@@ -1117,6 +1117,7 @@ static int cmd_subvol_show(const struct cmd_struct *cmd, int argc, char **argv)break ;free (subvol_path); + subvol_path =NULL ; }btrfs_util_destroy_subvolume_iterator (iter); }else {
Signature · 1 line
2.29.2
Quoted 11 lines · Su Yue
User reported that
btrfs subvolume show -u -- /mntcauses double free.Pointer
subovl_pathwas freed in iterations but still keeps old value. In the last iteration, errorBTRFS_UTIL_ERROR_STOP_ITERATIONreturned, then the double free ofsubvol_pathhappens in the out goto label.Set
subvol_pathto NULL after eachfree()in the loop to fix the issue.Links: https://github.com/kdave/btrfs-progs/issues/317
Signed-off-by Su Yue <[email protected]>
Thanks, added to devel.