summaryrefslogtreecommitdiffstats
path: root/ipa-client
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2012-12-06 15:52:05 -0500
committerRob Crittenden <rcritten@redhat.com>2012-12-07 09:41:44 -0500
commit0d836cd6ee9d7b29808cbf36582eed71a5b6a32a (patch)
tree4b33f798b7b7efc2feb2bc3fe5d5ab64d6ded92e /ipa-client
parent6cb7441d15f119e2571c8172e2cc34e9e32346db (diff)
downloadfreeipa-0d836cd6ee9d7b29808cbf36582eed71a5b6a32a.tar.gz
freeipa-0d836cd6ee9d7b29808cbf36582eed71a5b6a32a.tar.xz
freeipa-0d836cd6ee9d7b29808cbf36582eed71a5b6a32a.zip
Reorder XML-RPC initialization in ipa-join to avoid segfault.
There were a number of code paths where we would try to call xmlrpc_env_clean() without having first called xmlrpc_env_init() Re-order the code so we always initialize the XML-RPC client first. I also noticed a place where the return value of strdup() was not being checked for NULL. https://fedorahosted.org/freeipa/ticket/3275
Diffstat (limited to 'ipa-client')
-rw-r--r--ipa-client/ipa-join.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ipa-client/ipa-join.c b/ipa-client/ipa-join.c
index 4c3711319..64b4c0ac6 100644
--- a/ipa-client/ipa-join.c
+++ b/ipa-client/ipa-join.c
@@ -735,6 +735,13 @@ unenroll_host(const char *server, const char *hostname, const char *ktname, int
char * url = NULL;
char * user_agent = NULL;
+ /* Start up our XML-RPC client library. */
+ xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION);
+
+ xmlrpc_env_init(&env);
+
+ xmlrpc_client_setup_global_const(&env);
+
if (server) {
ipaserver = strdup(server);
} else {
@@ -755,6 +762,11 @@ unenroll_host(const char *server, const char *hostname, const char *ktname, int
host = strdup(hostname);
}
+ if (NULL == host) {
+ rval = 3;
+ goto cleanup;
+ }
+
if (NULL == strstr(host, ".")) {
if (!quiet)
fprintf(stderr, _("The hostname must be fully-qualified: %s\n"),
@@ -846,13 +858,6 @@ unenroll_host(const char *server, const char *hostname, const char *ktname, int
ccache = NULL;
putenv("KRB5CCNAME=MEMORY:ipa-join");
- /* Start up our XML-RPC client library. */
- xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION);
-
- xmlrpc_env_init(&env);
-
- xmlrpc_client_setup_global_const(&env);
-
#if 1
ret = asprintf(&url, "https://%s:443/ipa/xml", ipaserver);
#else