<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 have been really reading the code =D</DIV>
<DIV> </DIV>
<DIV>That function never is called on anything bigger than a 32 character string so </DIV>
<DIV>we may have never noticed that....</DIV>
<DIV> </DIV>
<DIV>Thank you I added it to trunk.</DIV>
<DIV> </DIV>
<DIV><BR> </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 <fanzhou@gmail.com><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 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 infinite loop.</DIV>
<DIV>2. anyway, after this function, there would be no "a" in the buf.</DIV>
<DIV>Please see the changes as followed.</DIV>
<DIV> </DIV>
<DIV>Index: freeswitch/src/switch_stun.c<BR>===================================================================<BR>--- freeswitch/src/switch_stun.c (revision 0)<BR>+++ freeswitch/src/switch_stun.c (working copy)<BR>@@ -91,18 +91,18 @@ <BR> {<BR> char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";<BR> int max;<BR>- uint8_t x;<BR>+ uint16_t x;<BR> <BR> if (!set) {<BR> set = chars;<BR> }<BR> <BR>- max = (int)strlen(set) - 1; <BR>+ max = (int)strlen(set);<BR> <BR> srand((unsigned int)apr_time_now());<BR> <BR> for(x = 0; x < len; x++) {<BR>- int j = 1+(int)(max*1.0*rand()/(RAND_MAX+1.0));<BR>+ int j = (int)(max*1.0*rand()/(RAND_MAX+1.0)); <BR> buf[x] = set[j];<BR> }<BR> }<BR> </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>