Bug 238020 - Memory leak in function gss_release_oid_set in crypto/heimdal/lib/gssapi/mech/gss_release_oid_set.c
Summary: Memory leak in function gss_release_oid_set in crypto/heimdal/lib/gssapi/mech...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-21 12:34 UTC by Young
Modified: 2023-12-28 11:38 UTC (History)
0 users

See Also:


Attachments
Proposed patch (1.26 KB, patch)
2019-05-21 12:34 UTC, Young
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Young 2019-05-21 12:34:19 UTC
Created attachment 204507 [details]
Proposed patch

There is a memory leak in gss_release_oid_set in crypto/heimdal/lib/gssapi/mech/gss_release_oid_set.c

GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_release_oid_set(OM_uint32 *minor_status,
    gss_OID_set *set)
{

        *minor_status = 0;
        if (set && *set) {
                if ((*set)->elements)
                        free((*set)->elements);
                free(*set);
                *set = GSS_C_NO_OID_SET;
        }
        return (GSS_S_COMPLETE);
}


typedef struct gss_OID_desc_struct {
      OM_uint32 length;
      void      *elements;
} gss_OID_desc, *gss_OID;
typedef const gss_OID_desc * gss_const_OID;

typedef struct gss_OID_set_desc_struct  {
      size_t     count;
      gss_OID    elements;
} gss_OID_set_desc, *gss_OID_set;

Since set is the pointer that points to gss_OID_set, then *set is the pointer that points to gss_OID_set_desc. There are two elements in the struct named count and elements. And elements is the pointer that points to gss_OID_desc. There are two elements named length and *elements. Therefore, we should free all elements in gss_OID_desc.

set -> gss_OID_set -> gss_OID_set_desc |count   |
                                       |elements| -> gss_OID_desc | length    |
                                                                  | *elements |

The attachment is the proposed patch.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2023-12-28 11:38:52 UTC
Comment on attachment 204507 [details]
Proposed patch

^Triage: convert this to text/plain and set the Patch flag so that the automation can see it.