[asterisk-dev] list operations in masquerade

Kevin P. Fleming kpfleming at digium.com
Wed Jun 17 06:59:59 CDT 2009


Stanis?aw Pitucha wrote:

> In ast_do_masquerade(), if the clonechan->readq is empty, it crashed
> our installation.
> AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list);
> This macro does not check if the source list is empty, so after it
> appends, original->readq->first is not NULL, but ...->last is NULL. It
> causes a crash later on, as original->readq becomes broken. We fixed
> it by updating the macro to:
> 
> #define AST_LIST_APPEND_LIST(head, list, field) do {    \
>      if ((list)->first) {    \
>                if (!(head)->first) {               \
>                         (head)->first = (list)->first;   \
>                         (head)->last = (list)->last;   \
>                } else {                           \
>                         (head)->last->field.next = (list)->first;  \
>                         (head)->last = (list)->last;    \
>                }       \
>       }        \
>       (list)->first = NULL; \
>       (list)->last = NULL; \
> } while (0)

Thanks for the report; the macro is indeed broken, and I'm committing a
slightly different fix.

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kpfleming at digium.com
Check us out at www.digium.com & www.asterisk.org




More information about the asterisk-dev mailing list