Clear error-string when introducing new errors.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16661 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-01-25 12:50:10 +00:00
parent 740309eb47
commit dbc39600e2
5 changed files with 29 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan * Copyright (c) 1997-2000, 2005-2006 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -96,8 +96,10 @@ kadm5_c_chpass_principal_with_key(void *server_handle,
return ret; return ret;
sp = krb5_storage_from_mem(buf, sizeof(buf)); sp = krb5_storage_from_mem(buf, sizeof(buf));
if (sp == NULL) if (sp == NULL) {
krb5_clear_error_string(context->context);
return ENOMEM; return ENOMEM;
}
krb5_store_int32(sp, kadm_chpass_with_key); krb5_store_int32(sp, kadm_chpass_with_key);
krb5_store_principal(sp, princ); krb5_store_principal(sp, princ);
krb5_store_int32(sp, n_key_data); krb5_store_int32(sp, n_key_data);
@@ -110,10 +112,12 @@ kadm5_c_chpass_principal_with_key(void *server_handle,
return ret; return ret;
sp = krb5_storage_from_data (&reply); sp = krb5_storage_from_data (&reply);
if (sp == NULL) { if (sp == NULL) {
krb5_clear_error_string(context->context);
krb5_data_free (&reply); krb5_data_free (&reply);
return ENOMEM; return ENOMEM;
} }
krb5_ret_int32(sp, &tmp); krb5_ret_int32(sp, &tmp);
krb5_clear_error_string(context->context);
krb5_storage_free(sp); krb5_storage_free(sp);
krb5_data_free (&reply); krb5_data_free (&reply);
return tmp; return tmp;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 - 1999 Kungliga Tekniska H<>gskolan * Copyright (c) 1997-2000, 2005-2006 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -53,8 +53,10 @@ kadm5_c_create_principal(void *server_handle,
return ret; return ret;
sp = krb5_storage_from_mem(buf, sizeof(buf)); sp = krb5_storage_from_mem(buf, sizeof(buf));
if (sp == NULL) if (sp == NULL) {
krb5_clear_error_string(context->context);
return ENOMEM; return ENOMEM;
}
krb5_store_int32(sp, kadm_create); krb5_store_int32(sp, kadm_create);
kadm5_store_principal_ent(sp, princ); kadm5_store_principal_ent(sp, princ);
krb5_store_int32(sp, mask); krb5_store_int32(sp, mask);
@@ -66,10 +68,12 @@ kadm5_c_create_principal(void *server_handle,
return ret; return ret;
sp = krb5_storage_from_data (&reply); sp = krb5_storage_from_data (&reply);
if (sp == NULL) { if (sp == NULL) {
krb5_clear_error_string(context->context);
krb5_data_free (&reply); krb5_data_free (&reply);
return ENOMEM; return ENOMEM;
} }
krb5_ret_int32(sp, &tmp); krb5_ret_int32(sp, &tmp);
krb5_clear_error_string(context->context);
krb5_storage_free(sp); krb5_storage_free(sp);
krb5_data_free (&reply); krb5_data_free (&reply);
return tmp; return tmp;

View File

@@ -50,8 +50,10 @@ kadm5_c_delete_principal(void *server_handle, krb5_principal princ)
return ret; return ret;
sp = krb5_storage_from_mem(buf, sizeof(buf)); sp = krb5_storage_from_mem(buf, sizeof(buf));
if (sp == NULL) if (sp == NULL) {
krb5_clear_error_string(context->context);
return ENOMEM; return ENOMEM;
}
krb5_store_int32(sp, kadm_delete); krb5_store_int32(sp, kadm_delete);
krb5_store_principal(sp, princ); krb5_store_principal(sp, princ);
ret = _kadm5_client_send(context, sp); ret = _kadm5_client_send(context, sp);
@@ -63,10 +65,12 @@ kadm5_c_delete_principal(void *server_handle, krb5_principal princ)
return ret; return ret;
sp = krb5_storage_from_data (&reply); sp = krb5_storage_from_data (&reply);
if(sp == NULL) { if(sp == NULL) {
krb5_clear_error_string(context->context);
krb5_data_free (&reply); krb5_data_free (&reply);
return ENOMEM; return ENOMEM;
} }
krb5_ret_int32(sp, &tmp); krb5_ret_int32(sp, &tmp);
krb5_clear_error_string(context->context);
krb5_storage_free(sp); krb5_storage_free(sp);
krb5_data_free (&reply); krb5_data_free (&reply);
return tmp; return tmp;

View File

@@ -368,8 +368,10 @@ kadm_connect(kadm5_client_context *ctx)
hostname = slash + 1; hostname = slash + 1;
error = getaddrinfo (hostname, portstr, &hints, &ai); error = getaddrinfo (hostname, portstr, &hints, &ai);
if (error) if (error) {
krb5_clear_error_string(context);
return KADM5_BAD_SERVER_NAME; return KADM5_BAD_SERVER_NAME;
}
for (a = ai; a != NULL; a = a->ai_next) { for (a = ai; a != NULL; a = a->ai_next) {
s = socket (a->ai_family, a->ai_socktype, a->ai_protocol); s = socket (a->ai_family, a->ai_socktype, a->ai_protocol);
@@ -384,6 +386,7 @@ kadm_connect(kadm5_client_context *ctx)
} }
if (a == NULL) { if (a == NULL) {
freeaddrinfo (ai); freeaddrinfo (ai);
krb5_clear_error_string(context);
krb5_warnx (context, "failed to contact %s", hostname); krb5_warnx (context, "failed to contact %s", hostname);
return KADM5_FAILURE; return KADM5_FAILURE;
} }
@@ -407,6 +410,7 @@ kadm_connect(kadm5_client_context *ctx)
if (service_name == NULL) { if (service_name == NULL) {
freeaddrinfo (ai); freeaddrinfo (ai);
close(s); close(s);
krb5_clear_error_string(context);
return ENOMEM; return ENOMEM;
} }
@@ -450,11 +454,13 @@ kadm_connect(kadm5_client_context *ctx)
s = socket (a->ai_family, a->ai_socktype, a->ai_protocol); s = socket (a->ai_family, a->ai_socktype, a->ai_protocol);
if (s < 0) { if (s < 0) {
freeaddrinfo (ai); freeaddrinfo (ai);
krb5_clear_error_string(context);
return errno; return errno;
} }
if (connect (s, a->ai_addr, a->ai_addrlen) < 0) { if (connect (s, a->ai_addr, a->ai_addrlen) < 0) {
close (s); close (s);
freeaddrinfo (ai); freeaddrinfo (ai);
krb5_clear_error_string(context);
return errno; return errno;
} }
ret = krb5_sendauth(context, &ctx->ac, &s, ret = krb5_sendauth(context, &ctx->ac, &s,
@@ -471,10 +477,6 @@ kadm_connect(kadm5_client_context *ctx)
krb5_free_principal(context, server); krb5_free_principal(context, server);
if(ctx->ccache == NULL) if(ctx->ccache == NULL)
krb5_cc_close(context, cc); krb5_cc_close(context, cc);
if(ret) {
close(s);
return ret;
}
ctx->sock = s; ctx->sock = s;
return 0; return 0;

View File

@@ -52,8 +52,10 @@ kadm5_c_modify_principal(void *server_handle,
return ret; return ret;
sp = krb5_storage_from_mem(buf, sizeof(buf)); sp = krb5_storage_from_mem(buf, sizeof(buf));
if (sp == NULL) if (sp == NULL) {
krb5_clear_error_string(context->contect);
return ENOMEM; return ENOMEM;
}
krb5_store_int32(sp, kadm_modify); krb5_store_int32(sp, kadm_modify);
kadm5_store_principal_ent(sp, princ); kadm5_store_principal_ent(sp, princ);
krb5_store_int32(sp, mask); krb5_store_int32(sp, mask);
@@ -66,10 +68,12 @@ kadm5_c_modify_principal(void *server_handle,
return ret; return ret;
sp = krb5_storage_from_data (&reply); sp = krb5_storage_from_data (&reply);
if (sp == NULL) { if (sp == NULL) {
krb5_clear_error_string(context->contect);
krb5_data_free (&reply); krb5_data_free (&reply);
return ENOMEM; return ENOMEM;
} }
krb5_ret_int32(sp, &tmp); krb5_ret_int32(sp, &tmp);
krb5_clear_error_string(context->contect);
krb5_storage_free(sp); krb5_storage_free(sp);
krb5_data_free (&reply); krb5_data_free (&reply);
return tmp; return tmp;