From: Daniel Gustafsson Date: Thu, 12 May 2022 12:11:52 +0000 (+0200) Subject: gssapi: improve handling of errors from gss_display_status X-Git-Tag: curl-7_84_0~205 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7360f9a5656b04d062cd86bfc1d045e526798d33;p=thirdparty%2Fcurl.git gssapi: improve handling of errors from gss_display_status In case gss_display_status() returns an error, avoid trying to add it to the buffer as the message may well be a NULL pointer. Originally this fix comes from a discussion in issue #8816. Closes: #8832 Reviewed-by: Jay Satiro --- diff --git a/lib/curl_gssapi.c b/lib/curl_gssapi.c index 1543a0ff46..52510f4433 100644 --- a/lib/curl_gssapi.c +++ b/lib/curl_gssapi.c @@ -98,10 +98,12 @@ static size_t display_gss_error(OM_uint32 status, int type, GSS_C_NO_OID, &msg_ctx, &status_string); - if(GSS_LOG_BUFFER_LEN > len + status_string.length + 3) { - len += msnprintf(buf + len, GSS_LOG_BUFFER_LEN - len, - "%.*s. ", (int)status_string.length, - (char *)status_string.value); + if(maj_stat == GSS_S_COMPLETE && status_string.length > 0) { + if(GSS_LOG_BUFFER_LEN > len + status_string.length + 3) { + len += msnprintf(buf + len, GSS_LOG_BUFFER_LEN - len, + "%.*s. ", (int)status_string.length, + (char *)status_string.value); + } } gss_release_buffer(&min_stat, &status_string); } while(!GSS_ERROR(maj_stat) && msg_ctx);