diff options
author | Martin Kosek <mkosek@redhat.com> | 2011-01-10 09:55:57 +0100 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-01-12 11:28:25 -0500 |
commit | e2d4e9477ee52e52712b65b532159720794969cb (patch) | |
tree | 32d96ac7305a2199c0c58fa052c83fd7a57c3345 /ipa-client | |
parent | 6503813608d05a94b998939a0efcbda0dbd40202 (diff) | |
download | freeipa-e2d4e9477ee52e52712b65b532159720794969cb.tar.gz freeipa-e2d4e9477ee52e52712b65b532159720794969cb.tar.xz freeipa-e2d4e9477ee52e52712b65b532159720794969cb.zip |
Uninitialized pointer read in ipa-rmkeytab
Fix "--realm" parameter processing in ipa-rmkeytab. Also make sure
that memory allocated in this process is also freed.
https://fedorahosted.org/freeipa/ticket/711
Diffstat (limited to 'ipa-client')
-rw-r--r-- | ipa-client/ipa-rmkeytab.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/ipa-client/ipa-rmkeytab.c b/ipa-client/ipa-rmkeytab.c index 0320045d..8afa9e1c 100644 --- a/ipa-client/ipa-rmkeytab.c +++ b/ipa-client/ipa-rmkeytab.c @@ -148,8 +148,8 @@ main(int argc, const char **argv) krb5_error_code krberr; krb5_keytab ktid; krb5_kt_cursor cursor; - char * ktname; - char * atrealm; + char * ktname = NULL; + char * atrealm = NULL; poptContext pc; static const char *keytab = NULL; static const char *principal = NULL; @@ -201,14 +201,20 @@ main(int argc, const char **argv) * the string we pass in looks like a realm. */ if (realm) { - if (realm[0] != '@') + if (realm[0] != '@') { ret = asprintf(&atrealm, "@%s", realm); if (ret == -1) { rval = 2; goto cleanup; } - else - atrealm = strcpy(atrealm, realm); + } else { + atrealm = strdup(realm); + + if (NULL == atrealm) { + rval = 2; + goto cleanup; + } + } } krberr = krb5_kt_resolve(context, ktname, &ktid); @@ -247,5 +253,8 @@ cleanup: poptFreeContext(pc); + free(atrealm); + free(ktname); + return rval; } |