]> granicus.if.org Git - strace/commitdiff
mount: robustify MS_MGC_VAL decoding
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 16 Jun 2015 01:28:34 +0000 (01:28 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 16 Jun 2015 01:30:49 +0000 (01:30 +0000)
* mount.c (sys_mount): When printing mount flags, do not assume that
(flags & MS_MGC_MSK) == MS_MGC_VAL.

mount.c

diff --git a/mount.c b/mount.c
index 7b30b3715ec212ef013b124ce6facf9660dcf38e..2f7f0caec0bfb0042b8d500c7cb63c58b6277278 100644 (file)
--- a/mount.c
+++ b/mount.c
 SYS_FUNC(mount)
 {
        if (entering(tcp)) {
-               int ignore_type = 0, ignore_data = 0;
+               bool ignore_type = false;
+               bool ignore_data = false;
+               bool old_magic = false;
                unsigned long flags = tcp->u_arg[3];
 
                /* Discard magic */
-               if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
+               if ((flags & MS_MGC_MSK) == MS_MGC_VAL) {
                        flags &= ~MS_MGC_MSK;
+                       old_magic = true;
+               }
 
                if (flags & MS_REMOUNT)
-                       ignore_type = 1;
+                       ignore_type = true;
                else if (flags & (MS_BIND | MS_MOVE))
-                       ignore_type = ignore_data = 1;
+                       ignore_type = ignore_data = true;
 
                printpath(tcp, tcp->u_arg[0]);
                tprints(", ");
@@ -59,7 +63,13 @@ SYS_FUNC(mount)
                        printstr(tcp, tcp->u_arg[2], -1);
                tprints(", ");
 
-               printflags(mount_flags, tcp->u_arg[3], "MS_???");
+               if (old_magic) {
+                       tprints("MS_MGC_VAL");
+                       if (flags)
+                               tprints("|");
+               }
+               if (flags || !old_magic)
+                       printflags(mount_flags, flags, "MS_???");
                tprints(", ");
 
                if (ignore_data && tcp->u_arg[4])