Changeset 4877


Ignore:
Timestamp:
Jan 31, 2008, 3:09:24 AM (15 years ago)
Author:
charles
Message:

(1.0x) fix off-by-one that was uncovered by the new benc's stricter parsing.

Location:
branches/1.0x/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0x/libtransmission/bencode-test.c

    r4875 r4877  
    215215    tr_bencFree( &val );
    216216
     217    end = NULL;
     218    snprintf( (char*)buf, sizeof( buf ), "d8:completei1e8:intervali1800e12:min intervali1800e5:peers0:e" );
     219    err = tr_bencLoad( buf, sizeof( buf ), &val, (char**)&end );
     220    check( !err );
     221    check( end == buf + strlen( (const char*)buf ) );
     222    tr_bencFree( &val );
     223
    217224    return 0;
    218225}
  • branches/1.0x/libtransmission/bencode.c

    r4875 r4877  
    292292            const uint8_t * end;
    293293            uint8_t * str;
    294             size_t strlen;
     294            size_t str_len;
    295295            int err;
    296296            benc_val_t * node;
    297297
    298             if(( err = tr_bencParseStr( buf, bufend, &end, &str, &strlen )))
     298            if(( err = tr_bencParseStr( buf, bufend, &end, &str, &str_len )))
    299299                return err;
    300300
     
    303303                return TR_ERROR;
    304304
    305             tr_bencInitStr( node, str, strlen, 0 );
     305            tr_bencInitStr( node, str, str_len, 0 );
    306306            buf = end;
    307307
     
    797797    struct WalkPrint * data = vdata;
    798798    printLeadingSpaces( data );
     799    fprintf( data->out, "string:  " );
    799800    for( ii = 0; val->val.s.i > ii; ii++ )
    800801    {
     
    808809        }
    809810    }
     811    fprintf( data->out, "\n" );
    810812}
    811813static void
  • branches/1.0x/libtransmission/tracker.c

    r4851 r4877  
    279279    const unsigned char * body = EVBUFFER_DATA( req->input_buffer );
    280280    const int bodylen = EVBUFFER_LENGTH( req->input_buffer );
    281     int ret = 1;
    282     int i;
    283 
    284     for( i=0; ret && i<bodylen; ++i )
    285         if( !tr_bencLoad( body+i, bodylen-1, setme, NULL ) )
    286             ret = 0;
    287 
    288     return ret;
     281    return tr_bencLoad( body, bodylen, setme, NULL );
    289282}
    290283
Note: See TracChangeset for help on using the changeset viewer.