imagehlp: improve last error handling in ImageGetCertificateData

Aric Stewart aric at codeweavers.com
Tue Dec 11 19:00:07 CST 2007


Humm,  I wrote a test program mimicking the calls in the application I 
am working on and found this behavior. The app was passing in a NULL 
buffer and a pointer for the size set to 0,  We where exiting with TRUE 
and not setting the last error correctly which was confusing the app. 
Testing on windows seems to show that we needed to set the size and set 
last error (and return FALSE).

I am not sure how i would set up a regression test since wouldn't we 
need an exe with a certificate in it to test with? There must be a 
programmatic way to set that up.

-aric

Juan Lang wrote:
> Hi Aric,
> 
> -    if( !Certificate )
> +    if( *RequiredLength < size )
>      {
>          *RequiredLength = size;
> -        return TRUE;
> +        SetLastError( ERROR_INSUFFICIENT_BUFFER );
> +        return FALSE;
>      }
> 
> -    if( *RequiredLength < size )
> +    if( !Certificate )
>      {
>          *RequiredLength = size;
> -        SetLastError( ERROR_INSUFFICIENT_BUFFER );
> -        return FALSE;
> +        return TRUE;
>      }
> 
> Are you sure this is the order that *RequiredLength and Certificate
> are checked in?  Seems backwards to the normal style to me.  I won't
> bug you for a proper regression test, as I failed to produce one too
> :)
> --Juan
> 
> 




More information about the wine-devel mailing list