Ignore:
Timestamp:
Oct 17, 2010, 6:32:55 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3638 "fewer crypto calls when creating peer-ids, session ids, announcer keys, etc" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r11183 r11333  
    101101        const char * pool = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    102102        const size_t pool_size = strlen( pool );
    103         char * buf = tr_new( char, n+1 );
    104 
     103        unsigned char * buf = tr_new( unsigned char, n+1 );
     104
     105        tr_cryptoRandBuf( buf, n );
    105106        for( i=0; i<n; ++i )
    106             buf[i] = pool[ tr_cryptoRandInt( pool_size ) ];
     107            buf[i] = pool[ buf[i] % pool_size ];
    107108        buf[n] = '\0';
    108109
    109110        tr_free( server->sessionId );
    110         server->sessionId = buf;
     111        server->sessionId = (char*) buf;
    111112        server->sessionIdExpiresAt = now + (60*60); /* expire in an hour */
    112113    }
Note: See TracChangeset for help on using the changeset viewer.