|
|
651382 |
From 70f30d61e7f5da178e47dcfc8feb083a17be74ff Mon Sep 17 00:00:00 2001
|
|
|
651382 |
From: Simo Sorce <simo@redhat.com>
|
|
|
651382 |
Date: Thu, 27 Aug 2020 12:32:06 -0400
|
|
|
651382 |
Subject: [PATCH] Initialize interposed mech list without allocation
|
|
|
651382 |
|
|
|
651382 |
While we had already fixed the leak here in main, the code performed
|
|
|
651382 |
unnecessary extra work, so just replacethe whole lot with a function
|
|
|
651382 |
that does not do any extra allocation or copy.
|
|
|
651382 |
|
|
|
651382 |
Signed-off-by: Simo Sorce <simo@redhat.com>
|
|
|
651382 |
[rharwood@redhat.com: commit message]
|
|
|
651382 |
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
|
|
|
651382 |
(cherry picked from commit 447d5352c2a81e219ccf04348a87b2ff25b7de15)
|
|
|
651382 |
(cherry picked from commit 4abda7e47551f39adfc074fc017f6006a4b91a19)
|
|
|
651382 |
---
|
|
|
651382 |
src/mechglue/gss_plugin.c | 31 ++++++++++++++++++++++++++-----
|
|
|
651382 |
1 file changed, 26 insertions(+), 5 deletions(-)
|
|
|
651382 |
|
|
|
651382 |
diff --git a/src/mechglue/gss_plugin.c b/src/mechglue/gss_plugin.c
|
|
|
651382 |
index b9813dc..79e04d0 100644
|
|
|
651382 |
--- a/src/mechglue/gss_plugin.c
|
|
|
651382 |
+++ b/src/mechglue/gss_plugin.c
|
|
|
651382 |
@@ -65,6 +65,8 @@ enum gpp_behavior gpp_get_behavior(void)
|
|
|
651382 |
return behavior;
|
|
|
651382 |
}
|
|
|
651382 |
|
|
|
651382 |
+static void gpp_init_special_available_mechs(const gss_OID_set mechs);
|
|
|
651382 |
+
|
|
|
651382 |
/* 2.16.840.1.113730.3.8.15.1 */
|
|
|
651382 |
const gss_OID_desc gssproxy_mech_interposer = {
|
|
|
651382 |
.length = 11,
|
|
|
651382 |
@@ -76,7 +78,6 @@ gss_OID_set gss_mech_interposer(gss_OID mech_type)
|
|
|
651382 |
gss_OID_set interposed_mechs;
|
|
|
651382 |
OM_uint32 maj, min;
|
|
|
651382 |
char *envval;
|
|
|
651382 |
- gss_OID_set special_mechs;
|
|
|
651382 |
|
|
|
651382 |
/* avoid looping in the gssproxy daemon by avoiding to interpose
|
|
|
651382 |
* any mechanism */
|
|
|
651382 |
@@ -119,8 +120,7 @@ gss_OID_set gss_mech_interposer(gss_OID mech_type)
|
|
|
651382 |
}
|
|
|
651382 |
|
|
|
651382 |
/* while there also initiaize special_mechs */
|
|
|
651382 |
- special_mechs = gpp_special_available_mechs(interposed_mechs);
|
|
|
651382 |
- (void)gss_release_oid_set(&min, &special_mechs);
|
|
|
651382 |
+ gpp_init_special_available_mechs(interposed_mechs);
|
|
|
651382 |
|
|
|
651382 |
done:
|
|
|
651382 |
if (maj != 0) {
|
|
|
651382 |
@@ -307,13 +307,13 @@ gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs)
|
|
|
651382 |
gss_OID n;
|
|
|
651382 |
uint32_t maj, min;
|
|
|
651382 |
|
|
|
651382 |
- item = gpp_get_special_oids();
|
|
|
651382 |
-
|
|
|
651382 |
maj = gss_create_empty_oid_set(&min, &amechs);
|
|
|
651382 |
if (maj) {
|
|
|
651382 |
return GSS_C_NO_OID_SET;
|
|
|
651382 |
}
|
|
|
651382 |
for (size_t i = 0; i < mechs->count; i++) {
|
|
|
651382 |
+ item = gpp_get_special_oids();
|
|
|
651382 |
+
|
|
|
651382 |
while (item) {
|
|
|
651382 |
if (gpp_is_special_oid(&mechs->elements[i])) {
|
|
|
651382 |
maj = gss_add_oid_set_member(&min,
|
|
|
651382 |
@@ -354,6 +354,27 @@ done:
|
|
|
651382 |
return amechs;
|
|
|
651382 |
}
|
|
|
651382 |
|
|
|
651382 |
+static void gpp_init_special_available_mechs(const gss_OID_set mechs)
|
|
|
651382 |
+{
|
|
|
651382 |
+ struct gpp_special_oid_list *item;
|
|
|
651382 |
+
|
|
|
651382 |
+ for (size_t i = 0; i < mechs->count; i++) {
|
|
|
651382 |
+ item = gpp_get_special_oids();
|
|
|
651382 |
+
|
|
|
651382 |
+ while (item) {
|
|
|
651382 |
+ if (gpp_is_special_oid(&mechs->elements[i]) ||
|
|
|
651382 |
+ gpp_special_equal(&item->special_oid, &mechs->elements[i])) {
|
|
|
651382 |
+ break;
|
|
|
651382 |
+ }
|
|
|
651382 |
+ item = gpp_next_special_oids(item);
|
|
|
651382 |
+ }
|
|
|
651382 |
+ if (item == NULL) {
|
|
|
651382 |
+ /* not found, add to static list */
|
|
|
651382 |
+ (void)gpp_new_special_mech(&mechs->elements[i]);
|
|
|
651382 |
+ }
|
|
|
651382 |
+ }
|
|
|
651382 |
+}
|
|
|
651382 |
+
|
|
|
651382 |
OM_uint32 gssi_internal_release_oid(OM_uint32 *minor_status, gss_OID *oid)
|
|
|
651382 |
{
|
|
|
651382 |
struct gpp_special_oid_list *item = NULL;
|