[Home]

Summary:ASTERISK-11123: Extra increment of req->headers in add_header function
Reporter:Makoto Dei (makoto)Labels:
Date Opened:2007-12-28 03:57:02.000-0600Date Closed:2007-12-28 12:22:57.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) sip-hdr-count-14-r95139.diff
Description:In add_header function of chan_sip.c, req->headers is incremented twice.
But I think that one of them is not necessary.
Comments:By: Sergey Tamkovich (sergee) 2007-12-28 04:51:52.000-0600

seems like a bug to me. Every even element of req->headers[] array is NULL because of it. This issue is present in 1.4 branch and in trunk.

Uploading Patch for removing this explicit increment.



By: Mark Michelson (mmichelson) 2007-12-28 09:13:52.000-0600

I agree that this double increment is buggy, but I would argue that instead of sergee's patch, the other increment should be removed. Because there's a check at the beginning of add_header() to see if req->headers is equal to SIP_MAX_HEADERS (and if it is, we return -1 and print a warning message), it means that if we reach the bottom of the function, req->headers will always be less than SIP_MAX_HEADERS prior to incrementing. Because of this, I think it's safe to unconditionally increment req->headers.

If my logic is flawed here, let me know.

By: Digium Subversion (svnbot) 2007-12-28 12:21:31.000-0600

Repository: asterisk
Revision: 95191

U   branches/1.4/channels/chan_sip.c

------------------------------------------------------------------------
r95191 | russell | 2007-12-28 12:21:30 -0600 (Fri, 28 Dec 2007) | 6 lines

Remove duplicate increment of the header count in the add_header() function.

(closes issue ASTERISK-11123)
Reported by: makoto
Patch provided by sergee, committed patch by me, inspired by comments from putnopvut

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

http://svn.digium.com/view/asterisk?view=rev&revision=95191

By: Digium Subversion (svnbot) 2007-12-28 12:22:57.000-0600

Repository: asterisk
Revision: 95192

_U  trunk/
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r95192 | russell | 2007-12-28 12:22:57 -0600 (Fri, 28 Dec 2007) | 14 lines

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

........
r95191 | russell | 2007-12-28 12:24:59 -0600 (Fri, 28 Dec 2007) | 6 lines

Remove duplicate increment of the header count in the add_header() function.

(closes issue ASTERISK-11123)
Reported by: makoto
Patch provided by sergee, committed patch by me, inspired by comments from putnopvut

........

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

http://svn.digium.com/view/asterisk?view=rev&revision=95192