iphlpapi: fix GetAdaptersAddresses return values

Timo Teräs timo.teras at iki.fi
Mon Dec 27 01:56:21 CST 2010


We should return ERROR_BUFFER_OVERFLOW always if the buffer
pointer is NULL (regardless of old buffer length).

Additionally, while strictly not defined, Windows seems to always
return the WCHAR members as valid pointers. This is easily verified
by checking the output of the example code at:
http://msdn.microsoft.com/en-us/library/aa365915%28v=VS.85%29.aspx
In Windows it will not print (null) ever. Some programs seem to
rely on this behaviour.

One test case which does not work at all without these changes is
available from:
http://www.ipv6style.jp/files/ipv6/en/apps/20060320_2/GetAdaptersAddresses-EN.c

This updates also the test cases to verify both changes, and
additionally fixes a memory leak in the tests code.
---
I also have a similar patch for wine stable branch (1.2.x tree).
The iphlpapi has been changed a lot recently, so the fix is
slightly different there.

 dlls/iphlpapi/iphlpapi_main.c  |    5 ++++-
 dlls/iphlpapi/tests/iphlpapi.c |   21 ++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-iphlpapi-fix-GetAdaptersAddresses-return-values.txt
Type: text/x-patch
Size: 2963 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20101227/34f0aa42/attachment-0001.bin>


More information about the wine-patches mailing list