From 4bff0fbb31714d0f58949658a288b8dc9e759a60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Sat, 23 Jul 2011 12:06:01 -0700 Subject: [PATCH] check for NULL as argument to krb5_{prepend,set}_error_message functions --- lib/krb5/error_string.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/krb5/error_string.c b/lib/krb5/error_string.c index 7a7b989b6..bebd4c490 100644 --- a/lib/krb5/error_string.c +++ b/lib/krb5/error_string.c @@ -59,6 +59,8 @@ krb5_clear_error_message(krb5_context context) * Set the context full error string for a specific error code. * The error that is stored should be internationalized. * + * The if context is NULL, no error string is stored. + * * @param context Kerberos 5 context * @param ret The error code * @param fmt Error string for the error code @@ -82,6 +84,8 @@ krb5_set_error_message(krb5_context context, krb5_error_code ret, /** * Set the context full error string for a specific error code. * + * The if context is NULL, no error string is stored. + * * @param context Kerberos 5 context * @param ret The error code * @param fmt Error string for the error code @@ -98,6 +102,9 @@ krb5_vset_error_message (krb5_context context, krb5_error_code ret, { int r; + if (context == NULL) + return; + HEIMDAL_MUTEX_lock(context->mutex); if (context->error_string) { free(context->error_string); @@ -114,6 +121,8 @@ krb5_vset_error_message (krb5_context context, krb5_error_code ret, * Prepend the context full error string for a specific error code. * The error that is stored should be internationalized. * + * The if context is NULL, no error string is stored. + * * @param context Kerberos 5 context * @param ret The error code * @param fmt Error string for the error code @@ -137,6 +146,8 @@ krb5_prepend_error_message(krb5_context context, krb5_error_code ret, /** * Prepend the contexts's full error string for a specific error code. * + * The if context is NULL, no error string is stored. + * * @param context Kerberos 5 context * @param ret The error code * @param fmt Error string for the error code @@ -151,6 +162,10 @@ krb5_vprepend_error_message(krb5_context context, krb5_error_code ret, __attribute__ ((format (printf, 3, 0))) { char *str = NULL, *str2 = NULL; + + if (context == NULL) + return; + HEIMDAL_MUTEX_lock(context->mutex); if (context->error_code != ret) { HEIMDAL_MUTEX_unlock(context->mutex); -- 2.11.4.GIT