[Home]

Summary:ASTERISK-16723: [patch] inefficient strlen() in ast_uri_decode loop
Reporter:Walter Doekes (wdoekes)Labels:
Date Opened:2010-09-23 15:29:52Date Closed:2011-01-19 13:04:26.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) astsvn-inefficient-ast-uri-decode.patch
Description:Hi,

ast_uri_decode features a loop in which for every '%' encountered strlen() is called. This is suboptimal.

Regards,
Walter
Comments:By: Stefan Schmidt (schmidts) 2010-09-23 16:30:06

i dont know if this would be possible in any racecondition, but if s is only one char long and set to '\0' your check wouldnt get this.
The for loop would accept it cause its not a NULL pointer.

By: Walter Doekes (wdoekes) 2010-09-24 15:59:19

Que? If s is one char long and set to '\0' then *s wouldn't be '%'.

By: Walter Doekes (wdoekes) 2010-09-24 16:07:13

Oh wait, did you think strlen() was some kind of atomic operation?

By: Stefan Schmidt (schmidts) 2010-09-24 16:12:36

yes allright to your que.

sorry i just have looked on your change and thought would could be caused by this and not hit the '%' before ;)



By: Digium Subversion (svnbot) 2011-01-19 13:02:30.000-0600

Repository: asterisk
Revision: 302554

U   branches/1.6.2/main/utils.c

------------------------------------------------------------------------
r302554 | seanbright | 2011-01-19 13:02:30 -0600 (Wed, 19 Jan 2011) | 7 lines

Don't call strlen() when we only need to look at the next character or two.

(closes issue ASTERISK-16723)
Reported by: wdoekes
Patches:
     astsvn-inefficient-ast-uri-decode.patch uploaded by wdoekes (license 717)

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

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

By: Digium Subversion (svnbot) 2011-01-19 13:03:33.000-0600

Repository: asterisk
Revision: 302555

_U  branches/1.8/
U   branches/1.8/main/utils.c

------------------------------------------------------------------------
r302555 | seanbright | 2011-01-19 13:03:33 -0600 (Wed, 19 Jan 2011) | 14 lines

Merged revisions 302554 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
 r302554 | seanbright | 2011-01-19 14:02:29 -0500 (Wed, 19 Jan 2011) | 7 lines
 
 Don't call strlen() when we only need to look at the next character or two.
 
 (closes issue ASTERISK-16723)
 Reported by: wdoekes
 Patches:
       astsvn-inefficient-ast-uri-decode.patch uploaded by wdoekes (license 717)
........

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

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

By: Digium Subversion (svnbot) 2011-01-19 13:04:26.000-0600

Repository: asterisk
Revision: 302556

_U  trunk/
U   trunk/main/utils.c

------------------------------------------------------------------------
r302556 | seanbright | 2011-01-19 13:04:25 -0600 (Wed, 19 Jan 2011) | 21 lines

Merged revisions 302555 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r302555 | seanbright | 2011-01-19 14:03:32 -0500 (Wed, 19 Jan 2011) | 14 lines
 
 Merged revisions 302554 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ........
   r302554 | seanbright | 2011-01-19 14:02:29 -0500 (Wed, 19 Jan 2011) | 7 lines
   
   Don't call strlen() when we only need to look at the next character or two.
   
   (closes issue ASTERISK-16723)
   Reported by: wdoekes
   Patches:
         astsvn-inefficient-ast-uri-decode.patch uploaded by wdoekes (license 717)
 ........
................

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

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