]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix issue pointed out by Fanzhou Zhao <fanzhou@gmail.com>
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Aug 2006 14:48:35 +0000 (14:48 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Aug 2006 14:48:35 +0000 (14:48 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2358 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_stun.c

index d4a48e1ca97f9dbeb03280c5fdd36ed467f2bc19..0f4b37c48483c8a8f3b3b468403bf8ea761f060c 100644 (file)
@@ -24,6 +24,7 @@
  * Contributor(s):
  * 
  * Anthony Minessale II <anthmct@yahoo.com>
+ * Fanzhou Zhao <fanzhou@gmail.com> 2006-08-22 (Bugfix 2357-2358)
  *
  *
  * switch_stun.c STUN (Simple Traversal of UDP over NAT)
@@ -91,18 +92,18 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se
 {
        char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        int max;
-       uint8_t x;
+       uint16_t x;
 
        if (!set) {
                set = chars;
        }
 
-       max = (int)strlen(set) - 1;
+       max = (int)strlen(set);
 
        srand((unsigned int)apr_time_now());
 
        for(x = 0; x < len; x++) {
-               int j = 1+(int)(max*1.0*rand()/(RAND_MAX+1.0));
+               int j = (int)(max*1.0*rand()/(RAND_MAX+1.0));
                buf[x] = set[j];
        }
 }