[Interest] It's time again to play Find-That-Bug

Paul Miller stelefx at gmail.com
Fri Sep 13 14:46:05 CEST 2013


On 9/13/2013 6:19 AM, Bill Crocker wrote:
> Hello:
>
> It's time again to play Find-That-Bug:
>
> I just spent several days tracking down a bug in the following code.
> It was difficult to find because it is a reduced probability,
> data-specific event; It can be completely function,
> completely dysfunctional, and all shades in between.
>
> I am using Qt 4.7.1
> Let's assume all of the input strings are ASCII.
>
> Can you find it?
>
>       QString
>       MakeDigest( QStringList list ) {
>           QCryptographicHash ch(QCryptographicHash::Md5);
>           foreach( QString s, list )
>               ch.addData( s.toAscii() );
>           return ch.result();
>       }

My guess is the "return ch.result()" line. You're returning a 
QByteArray(), which is being converted to a QString as ASCII (according 
to the QString docs), which is going to slice off your crypto data above 
127.




More information about the Interest mailing list