gss: intern OID before adding to OID set
authorLuke Howard <lukeh@padl.com>
Tue, 21 Apr 2020 04:54:18 +0000 (14:54 +1000)
committerNicolas Williams <nico@twosigma.com>
Tue, 21 Apr 2020 05:13:50 +0000 (00:13 -0500)
gss_add_oid_set_member() should according to RFC2744 add a copy of the OID to
the set; the current implementation just stored a pointer (which may not be
stable). As we have _gss_intern_oid(), call that before adding.

lib/gssapi/mech/gss_add_oid_set_member.c

index a23270511ebe4b24e4f5b5291d25237141d596c3..857422423ecd79aa3fb14335a5877e46eda84976 100644 (file)
@@ -34,9 +34,7 @@
 #include "mech_locl.h"
 
 /**
- * Add a oid to the oid set, function does not make a copy of the oid,
- * so the pointer to member_oid needs to be stable for the whole time
- * oid_set is used.
+ * Add a oid to the oid set.
  *
  * If there is a duplicate member of the oid, the new member is not
  * added to to the set.
@@ -56,7 +54,7 @@ gss_add_oid_set_member (OM_uint32 * minor_status,
                        const gss_OID member_oid,
                        gss_OID_set * oid_set)
 {
-    gss_OID tmp;
+    gss_OID tmp, interned_oid;
     size_t n;
     OM_uint32 res;
     int present;
@@ -77,8 +75,13 @@ gss_add_oid_set_member (OM_uint32 * minor_status,
        return GSS_S_FAILURE;
     }
     (*oid_set)->elements = tmp;
+
+    res = _gss_intern_oid(minor_status, member_oid, &interned_oid);
+    if (res != GSS_S_COMPLETE)
+       return res;
+
     (*oid_set)->count = n;
-    (*oid_set)->elements[n-1] = *member_oid;
+    (*oid_set)->elements[n-1] = *interned_oid;
     *minor_status = 0;
     return GSS_S_COMPLETE;
 }