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