Menu

#1793 potential double free() in oa_soap_event_thread()

3.2.1
closed-fixed
5
2013-06-20
2013-05-22
No

There is a potential double free going on in this function (should listen_for_events not be == to SAHPI_TRUE). Let's make it more robust:

diff --git a/openhpi/trunk/plugins/oa_soap/oa_soap_event.c b/openhpi/trunk/plugins/oa_soap/oa_soap_event.c
index 986b6e8..2d2947b 100644
--- a/openhpi/trunk/plugins/oa_soap/oa_soap_event.c
+++ b/openhpi/trunk/plugins/oa_soap/oa_soap_event.c
@@ -223,6 +223,7 @@ gpointer oa_soap_event_thread(gpointer oa_pointer)
sleep(2);
}
free(url);
+ url = NULL;

/* Intialize the event request structure */
request.pid = oa->event_pid;
@@ -304,7 +305,7 @@ oa->event_con2 failed\n");
} /* end of else (SOAP call failure handling) */

} /* end of 'while(listen_for_events == SAHPI_TRUE)' loop */
- free(url);
+ if (url != NULL) free(url);
return (gpointer *) SA_OK;
}

Discussion

  • dr_mohan

    dr_mohan - 2013-05-23

    url needs to be set to NULL after free.

     
  • dr_mohan

    dr_mohan - 2013-05-23
    • assigned_to: dr_mohan --> hemanthreddy
     
  • Hemantha Beecherla

    Thanks for filing the this bug,

    Below check is not necessary to free url.

    - free(url);
    + if (url != NULL) free(url);

    The final patch look like below,

    Index: plugins/oa_soap/oa_soap_event.c

    --- plugins/oa_soap/oa_soap_event.c (revision 7539)
    +++ plugins/oa_soap/oa_soap_event.c (working copy)
    @@ -223,6 +223,7 @@
    sleep(2);
    }
    free(url);
    + url = NULL;

    /* Intialize the event request structure */
    request.pid = oa->event_pid;

     
  • Hemantha Beecherla

    • milestone: --> 3.3.x
    • status: open --> open-accepted
     
  • Hemantha Beecherla

    Fixed in trunk revision #7540.

     
  • Hemantha Beecherla

    • status: open-accepted --> closed-fixed
     
  • dr_mohan

    dr_mohan - 2013-06-20
    • Group: 3.3.x --> 3.2.1