shlwapi: Resupply array sizes stripped by function interface

Andrew Talbot Andrew.Talbot at talbotville.com
Tue Sep 26 17:59:56 CDT 2006


Miko?aj Zalewski wrote:

>   I'm afraid this is worse than it was - if a separator will happen to
> be longer than 7 characters plus NUL you will write part the end of the
> buffer (the buffers in FormatInt and FormatDouble are 8 characters
> long). If you really want to support strings of any length you should
> allocate the buffer dynamically. But IMHO that would be a wait of time
> for you and the CPU executing such code. I'd expect #defining a constant
> for the 8 as the buffer length should be enough.
>   As for the changelog entry I'm not an expert but maybe "shlwapi:
> bugfix: sizeof(array passed as a parameter) can't be used to count it's
> elements" would be better?
> 
> Mikolaj Zalewski

I am now inclined to think - and in line with what you say - that it would be
safer and more efficient to modify FillNumberFmt() to take two more arguments
and pass the buffer sizes in as well, i.e., in effect, its declaration should
be:

static void
FillNumberFmt(NUMBERFMTW *fmt, LPWSTR decimal_buffer, int decbuf_wlen,
    LPSTR thousand_buffer, int thoubuf_wlen);

Does that sound better?

-- Andy.





More information about the wine-devel mailing list