[Toybox] [PATCH] Fix segfault with "mount -o ro,remount".
enh
enh at google.com
Tue Jun 30 17:50:29 PDT 2015
Fix segfault with "mount -o ro,remount".
Or any call to comma_scan where 'opt' appears as the last item in 'optlist'.
diff --git a/lib/getmountlist.c b/lib/getmountlist.c
index 30fb9a3..4fec41b 100644
--- a/lib/getmountlist.c
+++ b/lib/getmountlist.c
@@ -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);
}
}
diff --git a/tests/mount.test b/tests/mount.test
index 1fdc00f..d64bfc6 100755
--- a/tests/mount.test
+++ b/tests/mount.test
@@ -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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20150630/f7b4fdba/attachment-0003.htm>
More information about the Toybox
mailing list