<html><head><style type="text/css"><!-- DIV {margin:0px} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV></DIV>
<DIV>Wow, I'm impressed you must&nbsp;have been really reading the code =D</DIV>
<DIV>&nbsp;</DIV>
<DIV>That function never is called on anything bigger than a 32 character string&nbsp;so </DIV>
<DIV>we may have never noticed that....</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you I added it to trunk.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;</DIV>Anthony Minessale II<BR><BR>FreeSWITCH http://www.freeswitch.org/<BR>ClueCon http://www.cluecon.com/<BR><BR>AIM: anthm<BR>MSN:anthony_minessale@hotmail.com<BR>JABBER:anthony.minessale@gmail.com<BR><BR>FreeSWITCH Developer Conference<BR>sip:888@66.250.68.194<BR>iax:guest@66.250.68.194/888<BR>googletalk:freeswitch@gmail.com<BR>pstn:712-432-7800
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">----- Original Message ----<BR>From: Fanzhou Zhao &lt;fanzhou@gmail.com&gt;<BR>To: Freeswitch-dev@lists.freeswitch.org<BR>Sent: Tuesday, August 22, 2006 5:52:55 AM<BR>Subject: [Freeswitch-dev] bug of switch_stun_random_string<BR><BR>
<DIV>in the function&nbsp;switch_stun_random_string, there are two bugs.</DIV>
<DIV>1. the 2nd parameter len is uint16_t type, while the local varible x is uint8_t type. If sometimes len is larger than 0xFF, the for loop will be&nbsp;infinite loop.</DIV>
<DIV>2.&nbsp;anyway, after this function, there would be no&nbsp;"a" in the buf.</DIV>
<DIV>Please see the changes as followed.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Index: freeswitch/src/switch_stun.c<BR>===================================================================<BR>--- freeswitch/src/switch_stun.c&nbsp;(revision 0)<BR>+++ freeswitch/src/switch_stun.c&nbsp;(working copy)<BR>@@ -91,18 +91,18 @@ <BR>&nbsp;{<BR>&nbsp;&nbsp;char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";<BR>&nbsp;&nbsp;int max;<BR>-&nbsp;uint8_t x;<BR>+&nbsp;uint16_t x;<BR>&nbsp;<BR>&nbsp;&nbsp;if (!set) {<BR>&nbsp;&nbsp;&nbsp;set = chars;<BR>&nbsp;&nbsp;}<BR>&nbsp;<BR>-&nbsp;max = (int)strlen(set) - 1; <BR>+&nbsp;max = (int)strlen(set);<BR>&nbsp;<BR>&nbsp;&nbsp;srand((unsigned int)apr_time_now());<BR>&nbsp;<BR>&nbsp;&nbsp;for(x = 0; x &lt; len; x++) {<BR>-&nbsp;&nbsp;int j = 1+(int)(max*1.0*rand()/(RAND_MAX+1.0));<BR>+&nbsp;&nbsp;int j = (int)(max*1.0*rand()/(RAND_MAX+1.0)); <BR>&nbsp;&nbsp;&nbsp;buf[x] = set[j];<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>&nbsp;</DIV>
<DIV>_______________________________________________<BR>Freeswitch-dev mailing list<BR>Freeswitch-dev@lists.freeswitch.org<BR><A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</A><BR>UNSUBSCRIBE:<A href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target=_blank>http://lists.freeswitch.org/mailman/options/freeswitch-dev</A><BR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A></DIV></DIV><BR></DIV></div></body></html>