]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
gssapi: improve handling of errors from gss_display_status
authorDaniel Gustafsson <daniel@yesql.se>
Thu, 12 May 2022 12:11:52 +0000 (14:11 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Thu, 12 May 2022 12:11:52 +0000 (14:11 +0200)
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 <raysatiro@yahoo.com>
lib/curl_gssapi.c

index 1543a0ff46931b34316fb4f3a047e7abe432884f..52510f4433d0335ac06cdbe142eaa123d24877b3 100644 (file)
@@ -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);