Allow anonymous name to be imported with empty name buffer
authorGreg Hudson <ghudson@mit.edu>
Wed, 6 Apr 2011 20:06:50 +0000 (20:06 +0000)
committerGreg Hudson <ghudson@mit.edu>
Wed, 6 Apr 2011 20:06:50 +0000 (20:06 +0000)
When importing a name of type GSS_C_NT_ANONYMOUS, allow the input name
buffer to be null or empty (null is translated into empty before
mechanisms see it).

From r24820 in users/lhoward/moonshot-mechglue-fixes.

ticket: 6896

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24852 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/mechglue/g_imp_name.c

index e5179e7c987b8dfc3e743bed6e82c2bc24ff9d72..7afa188e53c79f150bc9f794165ce86d125574e2 100644 (file)
@@ -65,15 +65,19 @@ val_imp_name_args(
     if (input_name_buffer == GSS_C_NO_BUFFER)
        return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
 
-    if (input_name_buffer->length == 0)
-       return GSS_S_BAD_NAME;
+    if (input_name_type == GSS_C_NO_OID ||
+       !g_OID_equal(input_name_type, GSS_C_NT_ANONYMOUS)) {
+       if (input_name_buffer->length == 0)
+           return (GSS_S_BAD_NAME);
 
-    if (input_name_buffer->value == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+       if (input_name_buffer->value == NULL)
+           return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+    }
 
     return (GSS_S_COMPLETE);
 }
 
+static gss_buffer_desc emptyNameBuffer;
 
 OM_uint32 KRB5_CALLCONV
 gss_import_name(minor_status,
@@ -90,6 +94,9 @@ gss_name_t *          output_name;
     gss_union_name_t   union_name;
     OM_uint32          tmp, major_status = GSS_S_FAILURE;
 
+    if (input_name_buffer == GSS_C_NO_BUFFER)
+       input_name_buffer = &emptyNameBuffer;
+
     major_status = val_imp_name_args(minor_status,
                                     input_name_buffer, input_name_type,
                                     output_name);