Alexander Traud wrote:
In a patch of mine (DANE for Asterisk 13/chan_sip; available on request), a
char* was added in the struct ast_sockaddr to store the DNSSEC failure
reason (why_bogus). Not to create any memory leaks, this pointer has to be
freed. For this, the pointer must be initialized to NULL, for example via
struct ast_sockaddr variable_name = { 0 }. Otherwise, I create a
segmentation fault because I free a non-valid address. Long story short:

Neither GCC nor Clang are able to find uninitialized structs in Asterisk,
although the warning flag -Wall includes -Wuninitialized. And I played
around with the optimization in CFLAG. Mhm.

What shall I do?
A) Init all ast_sockaddr (and all structures containing ast_sockaddr).
    With the default sample configuration, just 5 files must be changed.
However, I searched with the regular expression "struct [^ ]+ [^*=)]+;" and
found 2408 lines of code in 418 files which may be uninitialized. As an
external project member, I cannot change/commit all of them. For a start,
shall I create issue report just about these 5 files?

B) Change my patch not to use a char* but char[128].

Your easiest option with less chance of regression elsewhere would be this.

--
Joshua Colp
Digium, Inc. | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to