1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

(trunk, libT) fix code in the UTF8-to-JSON serializer that could fall into an infinite loop when fed some inputs. This may be ticket #2326 or may get its own retroactive ticket, depending on feedback from #2326's reporter

This commit is contained in:
Charles Kerr 2009-09-02 15:26:34 +00:00
parent 5304a133ac
commit 515a3f986f

View file

@ -1339,9 +1339,7 @@ jsonStringFunc( const tr_benc * val, void * vdata )
UTF32 buf = 0; UTF32 buf = 0;
UTF32 * u32 = &buf; UTF32 * u32 = &buf;
ConversionResult result = ConvertUTF8toUTF32( &tmp, end, &u32, &buf + 1, 0 ); ConversionResult result = ConvertUTF8toUTF32( &tmp, end, &u32, &buf + 1, 0 );
if( ( result != conversionOK ) && ( tmp == it ) ) if((( result==conversionOK ) || (result==targetExhausted)) && (tmp!=it)) {
++it; /* it's beyond help; skip it */
else {
evbuffer_add_printf( data->out, "\\u%04x", (unsigned int)buf ); evbuffer_add_printf( data->out, "\\u%04x", (unsigned int)buf );
it = tmp - 1; it = tmp - 1;
} }