OSDN Git Service

Fix segfault with "mount -o ro,remount".
authorElliott Hughes <enh@google.com>
Wed, 1 Jul 2015 20:00:06 +0000 (15:00 -0500)
committerRob Landley <rob@landley.net>
Wed, 1 Jul 2015 20:00:06 +0000 (15:00 -0500)
Or any call to comma_scan where 'opt' appears as the last item in 'optlist'.

lib/getmountlist.c
tests/mount.test

index 30fb9a3..4fec41b 100644 (file)
@@ -78,7 +78,7 @@ int comma_scan(char *optlist, char *opt, int clean)
     no = 2*(*s == 'n' && s[1] == 'o');
     if (optlen == len-no && !strncmp(opt, s+no, optlen)) {
       got = !no;
-      if (clean) memmove(s, optlist, strlen(optlist)+1);
+      if (clean && optlist) memmove(s, optlist, strlen(optlist)+1);
     }
   }
 
index 1fdc00f..d64bfc6 100755 (executable)
@@ -82,6 +82,10 @@ testing "mount -o ro $tmp_b_fs /mnt" \
   "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 &&
    mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" ""
 reCreateTmpFs
+testing "mount -o ro,remount $tmp_b_fs /mnt" \
+  "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 &&
+   mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" ""
+reCreateTmpFs
 
 umount testDir1
 rm -f $tmp_b_fs