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:
parent
5304a133ac
commit
515a3f986f
1 changed files with 1 additions and 3 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue