]> granicus.if.org Git - strace/commitdiff
Fix a few goofs in sys_sysctl()
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 16 May 2012 10:23:58 +0000 (12:23 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 16 May 2012 10:23:58 +0000 (12:23 +0200)
* system.c (sys_sysctl): Cast pointer to long, not size_t,
when we intend to use it as an address. Set oldlen to 0 prior
to reading into it - we want to have deterministic result
if read fails.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
system.c

index 8efe90efd7533ea8d1c8d8f06dab4e09633a9017..270bd5b3507a69b6f736ad3d84eaed6d07212a78 100644 (file)
--- a/system.c
+++ b/system.c
@@ -951,8 +951,8 @@ sys_sysctl(struct tcb *tcp)
                        tprints(", ...");
                tprintf("}, %d, ", info.nlen);
        } else {
-               size_t oldlen;
-               if (umove(tcp, (size_t)info.oldlenp, &oldlen) >= 0
+               size_t oldlen = 0;
+               if (umove(tcp, (long)info.oldlenp, &oldlen) >= 0
                    && info.nlen >= 2
                    && ((name[0] == CTL_KERN
                         && (name[1] == KERN_OSRELEASE
@@ -978,7 +978,6 @@ sys_sysctl(struct tcb *tcp)
                                info.oldval, (unsigned long)oldlen,
                                info.newval, (unsigned long)info.newlen);
                }
-               tprints("}");
        }
 
        free(name);