libads: Fix free of uninitialized pointer
authorUri Simchoni <urisimchoni@gmail.com>
Sat, 2 May 2015 10:44:52 +0000 (13:44 +0300)
committerJeremy Allison <jra@samba.org>
Mon, 4 May 2015 16:24:21 +0000 (18:24 +0200)
In ads_keytab_creat_default(), if the keytab to be created cannot
be opened, the bail-out code calls smb_krb5_kt_free_entry() on
an uninitialized entry.

To reproduce:
1. Join a domain
2. KRB5_KTNAME=FILE:/non-existant-path/krb5.keytab net ads keytab create -P

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libads/kerberos_keytab.c

index bbd981c6159fbe6f7068c523e9e0c09a69b78e3b..ef6374ae7bed278c4ab4a94ddbe6c40f1a23c17c 100644 (file)
@@ -520,6 +520,9 @@ int ads_keytab_create_default(ADS_STRUCT *ads)
        size_t i;
        ADS_STATUS status;
 
+       ZERO_STRUCT(kt_entry);
+       ZERO_STRUCT(cursor);
+
        frame = talloc_stackframe();
        if (frame == NULL) {
                ret = -1;
@@ -575,8 +578,6 @@ int ads_keytab_create_default(ADS_STRUCT *ads)
 #endif
 
        memset(princ_s, '\0', sizeof(princ_s));
-       ZERO_STRUCT(kt_entry);
-       ZERO_STRUCT(cursor);
 
        initialize_krb5_error_table();
        ret = krb5_init_context(&context);