[asterisk-dev] (unreported) uninitialized: struct ast_sockaddr

Alexander Traud pabstraud at compuserve.com
Wed May 13 03:59:44 CDT 2015

> What you're proposing is a change to the semantics of ast_sockaddr.

Not sure what you mean by semantics. Please, let us ignore ast_sockaddr for
a second and see <http://www.ex-parrot.com/~chris/random/initialise.html>:

Currently, when a struct with "automatic storage duration" is created in
Asterisk, it is initialized
A) (correct) with {0},
B) (questionable) via memset,
C) (questionable) at first use, or
D) (wrong) not at all.

Is case D important enough to get fixed, at a whole, or partially. If
partially, to which extend?

Example 1:
The *opaque* peercnt (channels/chan_iax2.c) contains ast_sockaddr and
therefore has to be initialized correctly in my case to avoid a wild
pointer. Actually, I am using chan_sip only, added a pointer to
ast_sockaddr, cleaned memory, and my Asterisk was segfaulting in a complete
different module (chan_iax2.c). [Offtopic: Yes, my modules.conf was wrong.]

Example 2:
The *private* sip_peer (channels/sip/include/sip.h) contains pointers and is
not initialized at all twice, at least (sip_peer tmp_peer). This creates
wild pointers which segfaulted the pointer in my ast_sockaddr.

Asked differently:
I have a diff/patch correcting just the struct-inits for 62 lines of code at
54 places in 5 files, which affects my downstream code. Am I allowed to
commit just that, although it does not address the issue at a whole (there
are many more struct inits which stay wrong)?

Or: Is my compiler configured incorrectly somehow, not setting pointers to
(void *)0 automatically in structs with automatic storage duration?

More information about the asterisk-dev mailing list