Merge branch 'master' into tlv-mic
[mech_eap.orig] / display_status.c
index 5033620..b3cf2f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, JANET(UK)
+ * Copyright (c) 2011, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -99,7 +99,7 @@ saveStatusInfoNoCopy(OM_uint32 minor, char *message)
     p->code = minor;
     p->message = message;
 
-    if (p != NULL)
+    if (next != NULL)
         *next = p;
     else
         GSSEAP_SETSPECIFIC(gssEapStatusInfoKey, p);
@@ -125,16 +125,17 @@ getStatusInfo(OM_uint32 minor)
 void
 gssEapSaveStatusInfo(OM_uint32 minor, const char *format, ...)
 {
-    char *s;
+    char *s = NULL;
     int n;
     va_list ap;
 
-    va_start(ap, format);
-    n = vasprintf(&s, format, ap);
-    va_end(ap);
+    if (format != NULL) {
+        va_start(ap, format);
+        n = vasprintf(&s, format, ap);
+        va_end(ap);
+    }
 
-    if (n >= 0)
-        saveStatusInfoNoCopy(minor, s);
+    saveStatusInfoNoCopy(minor, s);
 }
 
 OM_uint32
@@ -157,7 +158,8 @@ gss_display_status(OM_uint32 *minor,
         return GSS_S_BAD_MECH;
     }
 
-    if (status_type != GSS_C_MECH_CODE) {
+    if (status_type != GSS_C_MECH_CODE ||
+        *message_context != 0) {
         /* we rely on the mechglue for GSS_C_GSS_CODE */
         *minor = 0;
         return GSS_S_BAD_STATUS;