[shlwapi] Add NULL checks to StrCpyW and StrCatW

carlo.bramix at libero.it carlo.bramix at libero.it
Sat Apr 14 14:01:02 CDT 2012


>From Bug #25261:

I looked the terminal output in the attachment of this bug and then I did some 
debugging on Windows.
I tested StrCpyW and also StrCatW (my intuition suggested me to do so) and I 
discovered that:

StrCpyW(myDestination, mySource) does not crash, it copies the content of 
mySource into myDestination, pointer to myDestination is returned.

StrCpyW(myDestination, NULL) does not crash, it leaves myDestination 
unchanged, pointer to myDestination is returned.

StrCpyW(NULL, NULL) does not crash, it returns NULL.

StrCatW has the same behavior of StrCpyW.
Actually, it seems to me that many string functions implemented into shlwapi 
are already protected against wrong parameters, evidently StrCpyW and StrCatW 
have need the same fixes that have been made elsewhere, since strcpyW and 
strcatW don't do it.
Attached patch should fix the defect, it just adds the test if both parameters 
are not NULL before proceeding to the copy.

Sincerely,

Carlo Bramini.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: string.txt
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20120414/db70adf5/attachment.txt>


More information about the wine-patches mailing list