[Home]

Summary:ASTERISK-10031: AST_LIST_REMOVE problems
Reporter:mihai (mihai)Labels:
Date Opened:2007-08-06 10:16:31Date Closed:2007-08-06 11:33:57
Priority:MinorRegression?No
Status:Closed/CompleteComponents:General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:in linkedlists.h, at or around line 744 we have:

__res = curelm;

This will return the incorrect element (the one before the correct element). The correct code would be:

__res = curelm->field.next;

Up until now, the return value of AST_LIST_REMOVE was not used anywhere in Asterisk.  However, Russell's latest patch to 10289 makes use of that return value

Also, if elm is NULL, then AST_LIST_REMOVE will crash.  Not checking for NULL arguments is a more generic problem that is present in other list related macros as well.

****** ADDITIONAL INFORMATION ******

Problem detected in 1.4.9, but present in trunk as well.
Comments:By: Russell Bryant (russell) 2007-08-06 11:31:21

I think it's safe to assume that elm should never be NULL.  Like you said, it's an assumption made in a lot of the macros.  But, if you wanted to write a patch for it, I would probably apply it anyway, since it can't hurt.

By: Digium Subversion (svnbot) 2007-08-06 11:33:22

Repository: asterisk
Revision: 78184

------------------------------------------------------------------------
r78184 | russell | 2007-08-06 11:33:21 -0500 (Mon, 06 Aug 2007) | 5 lines

Fix the return value of AST_LIST_REMOVE().  This shouldn't be causing any
problems, though, because the only code that uses the return value only checks
to see if it is NULL.
(closes issue ASTERISK-10031, pointed out by mihai)

------------------------------------------------------------------------

By: Digium Subversion (svnbot) 2007-08-06 11:33:57

Repository: asterisk
Revision: 78185

------------------------------------------------------------------------
r78185 | russell | 2007-08-06 11:33:57 -0500 (Mon, 06 Aug 2007) | 13 lines

Merged revisions 78184 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r78184 | russell | 2007-08-06 11:50:54 -0500 (Mon, 06 Aug 2007) | 5 lines

Fix the return value of AST_LIST_REMOVE().  This shouldn't be causing any
problems, though, because the only code that uses the return value only checks
to see if it is NULL.
(closes issue ASTERISK-10031, pointed out by mihai)

........

------------------------------------------------------------------------