cifs.upcall: fix crash when trying to free uninitialized var
authorJeff Layton <jlayton@samba.org>
Wed, 5 Jan 2011 15:52:19 +0000 (10:52 -0500)
committerJeff Layton <jlayton@samba.org>
Wed, 5 Jan 2011 15:52:19 +0000 (10:52 -0500)
If cifs.upcall is passed an invalid argument then it will "goto out".
The decoded_args struct however is uninitialized at that point so it
will usually segfault when trying to free fields in it. Move the
initialization up in the function.

Signed-off-by: Jeff Layton <jlayton@samba.org>
cifs.upcall.c

index 1ffcd7cda2d96794e8fd18efd320a223c10fa122..34b0638fb39906a09aa8d62144705fced11cf172 100644 (file)
@@ -677,6 +677,7 @@ int main(const int argc, char *const argv[])
        const char *oid;
 
        hostbuf[0] = '\0';
+       memset(&arg, 0, sizeof(arg));
 
        openlog(prog, 0, LOG_DAEMON);
 
@@ -731,8 +732,6 @@ int main(const int argc, char *const argv[])
                goto out;
        }
 
-       memset(&arg, 0, sizeof(arg));
-
        have = decode_key_description(buf, &arg);
        SAFE_FREE(buf);
        if ((have & DKD_MUSTHAVE_SET) != DKD_MUSTHAVE_SET) {