careful initializing out parameters in gss_inquire_name
authorLuke Howard <lukeh@padl.com>
Sun, 19 Sep 2010 21:09:28 +0000 (23:09 +0200)
committerLuke Howard <lukeh@padl.com>
Sun, 19 Sep 2010 21:09:28 +0000 (23:09 +0200)
mech_eap/gssapiP_eap.h
mech_eap/inquire_name.c

index 40dbdb8..bb61a01 100644 (file)
 #include <common.h>
 #include <eap_peer/eap.h>
 #include <eap_peer/eap_config.h>
-#include <crypto/tls.h>                     /* XXX testing implementation only */
+#include <crypto/tls.h>
 #include <wpabuf.h>
 #endif
 
+/* These name flags are informative and not actually used by anything yet */
 #define NAME_FLAG_NAI                       0x00000001
 #define NAME_FLAG_SERVICE                   0x00000002
 #define NAME_FLAG_COMPOSITE                 0x00000004
@@ -68,7 +69,7 @@ struct gss_eap_saml_attr_ctx;
 struct gss_eap_attr_ctx;
 
 struct gss_name_struct {
-    GSSEAP_MUTEX mutex; /* mutex protecting attributes */
+    GSSEAP_MUTEX mutex; /* mutex protects attrCtx */
     OM_uint32 flags;
     krb5_principal krbPrincipal; /* this is immutable */
     struct gss_eap_attr_ctx *attrCtx;
index e01cc61..586e862 100644 (file)
@@ -40,15 +40,21 @@ OM_uint32 gss_inquire_name(OM_uint32 *minor,
 {
     OM_uint32 major, tmpMinor;
 
-    *name_is_MN = 1;
-    *MN_mech = GSS_EAP_MECHANISM;
-    *attrs = GSS_C_NO_BUFFER_SET;
+    if (name_is_MN != NULL)
+        *name_is_MN = 1;
+    if (MN_mech != NULL)
+        *MN_mech = GSS_EAP_MECHANISM;
+    if (attrs != NULL)
+        *attrs = GSS_C_NO_BUFFER_SET;
 
     if (name == GSS_C_NO_NAME) {
         *minor = EINVAL;
         return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME;
     }
 
+    if (attrs == NULL)
+        return GSS_S_COMPLETE;
+
     GSSEAP_MUTEX_LOCK(&name->mutex);
 
     major = gssEapInquireName(minor, name, name_is_MN, MN_mech, attrs);