mount.cifs: Fix double-free issue when mounting with setuid root
authorPaulo Alcantara (SUSE) <paulo@paulo.ac>
Thu, 5 Sep 2019 18:49:35 +0000 (15:49 -0300)
committerPavel Shilovsky <pshilov@microsoft.com>
Fri, 4 Oct 2019 00:21:02 +0000 (17:21 -0700)
commitd7d78d7298b335e5c42567ae87b3f366e6c7f899
treea396005e9ea30df4ba87844527f04a55bb93ba9d
parent5a468f3dcbea4bfbc380a3f86466b8e33bc40570
mount.cifs: Fix double-free issue when mounting with setuid root

It can be easily reproduced with the following:

  # chmod +s `which mount.cifs`
  # echo "//localhost/share /mnt cifs \
    users,username=foo,password=XXXX" >> /etc/fstab
  # su - foo
  $ mount /mnt
  free(): double free detected in tcache 2
  Child process terminated abnormally.

The problem was that check_fstab() already freed orgoptions pointer
and then we freed it again in main() function.

Fixes: bf7f48f4c7dc ("mount.cifs.c: fix memory leaks in main func")
Signed-off-by: Paulo Alcantara (SUSE) <paulo@paulo.ac>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
mount.cifs.c