[Home]

Summary:ASTERISK-28572: Memory leaks in res_calendar_exchange and res_calendar_icalendar
Reporter:Yoooooo Ha (Yooooooha)Labels:
Date Opened:2019-10-07 08:55:36Date Closed:2019-10-29 09:40:26
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_calendar_exchange Resources/res_calendar_icalendar
Versions:16.6.0 Frequency of
Occurrence
Related
Issues:
Environment:NoAttachments:
Description:Edit:
exchangecal_destructor in res/res_calendar_exchange.c
icalendar_destructor in res/res_calendar_icalendar.c

{code}
struct exchangecal_pvt {
        AST_DECLARE_STRING_FIELDS(
                AST_STRING_FIELD(url);
                AST_STRING_FIELD(user);
                AST_STRING_FIELD(secret);
        );
        struct ast_calendar *owner;
        ne_uri uri;
        ne_session *session;
        struct ao2_container *events;
};
static void exchangecal_destructor(void *obj)
{
        struct exchangecal_pvt *pvt = obj;

        ast_debug(1, "Destroying pvt for Exchange calendar %s\n",
pvt->owner->name);
        if (pvt->session) {
                ne_session_destroy(pvt->session);
        }
        ast_string_field_free_memory(pvt);

        ao2_callback(pvt->events, OBJ_UNLINK | OBJ_NODATA |
OBJ_MULTIPLE, NULL, NULL);

        ao2_ref(pvt->events, -1);
}
{code}

{code}
struct icalendar_pvt {
        AST_DECLARE_STRING_FIELDS(
                AST_STRING_FIELD(url);
                AST_STRING_FIELD(user);
                AST_STRING_FIELD(secret);
        );
        struct ast_calendar *owner;
        ne_uri uri;
        ne_session *session;
        icalcomponent *data;
        struct ao2_container *events;
};
static void icalendar_destructor(void *obj)
{
        struct icalendar_pvt *pvt = obj;

        ast_debug(1, "Destroying pvt for iCalendar %s\n",
pvt->owner->name);
        if (pvt->session) {
                ne_session_destroy(pvt->session);
        }
        if (pvt->data) {
                icalcomponent_free(pvt->data);
        }
        ast_string_field_free_memory(pvt);

        ao2_callback(pvt->events, OBJ_UNLINK | OBJ_NODATA |
OBJ_MULTIPLE, NULL, NULL);

        ao2_ref(pvt->events, -1);
}
{code}

As we can see, the object uri is not freed in these two functions.
The vulnerability is same as the one fixed in
https://gerrit.asterisk.org/c/asterisk/+/6509
(ASTERISK-25524)
Comments:By: Asterisk Team (asteriskteam) 2019-10-07 08:55:37.214-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Benjamin Keith Ford (bford) 2019-10-07 09:32:33.856-0500

This does look like "ne_uri" is never freed - opening up an internal issue for this.

By: Friendly Automation (friendly-automation) 2019-10-29 09:40:26.932-0500

Change 13107 merged by Friendly Automation:
res_calendar: Resolve memory leak on calendar destruction

[https://gerrit.asterisk.org/c/asterisk/+/13107|https://gerrit.asterisk.org/c/asterisk/+/13107]

By: Friendly Automation (friendly-automation) 2019-10-29 10:27:27.694-0500

Change 13108 merged by Joshua Colp:
res_calendar: Resolve memory leak on calendar destruction

[https://gerrit.asterisk.org/c/asterisk/+/13108|https://gerrit.asterisk.org/c/asterisk/+/13108]

By: Friendly Automation (friendly-automation) 2019-10-29 10:27:38.678-0500

Change 13110 merged by Joshua Colp:
res_calendar: Resolve memory leak on calendar destruction

[https://gerrit.asterisk.org/c/asterisk/+/13110|https://gerrit.asterisk.org/c/asterisk/+/13110]

By: Friendly Automation (friendly-automation) 2019-10-29 10:27:49.154-0500

Change 13109 merged by Joshua Colp:
res_calendar: Resolve memory leak on calendar destruction

[https://gerrit.asterisk.org/c/asterisk/+/13109|https://gerrit.asterisk.org/c/asterisk/+/13109]