From: Dagfinn Reiakvam dagfinn@reiakvam.no
--- dlls/iphlpapi/iphlpapi.spec | 2 +- dlls/iphlpapi/iphlpapi_main.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec index b6c9aef..bbd1ed8 100644 --- a/dlls/iphlpapi/iphlpapi.spec +++ b/dlls/iphlpapi/iphlpapi.spec @@ -23,7 +23,7 @@ @ stdcall ConvertInterfaceNameToLuidW( wstr ptr ) #@ stub ConvertInterfacePhysicalAddressToLuid #@ stub ConvertIpv4MaskToLength -#@ stub ConvertLengthToIpv4Mask +@ stdcall ConvertLengthToIpv4Mask( long ptr ) #@ stub ConvertRemoteInterfaceAliasToLuid #@ stub ConvertRemoteInterfaceGuidToLuid #@ stub ConvertRemoteInterfaceIndexToLuid diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 97284ed..891f8f0 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -3223,6 +3223,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid) }
/****************************************************************** + * ConvertLengthToIpv4Mask (IPHLPAPI.@) + */ +DWORD WINAPI ConvertLengthToIpv4Mask(ULONG MaskLength, PULONG Mask) +{ + if(MaskLength <= 32) + return ERROR_INVALID_PARAMETER; + *Mask = 0xffffffff << ( 32 - MaskLength ); + return NO_ERROR; +} + +/****************************************************************** * if_nametoindex (IPHLPAPI.@) */ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
Hi Uberdaff,
On success,*ConvertLengthToIpv4Mask*returns*NO_ERROR*. Any nonzero return value indicates failure and the/Mask/parameter is set to*INADDR_NONE*defined in the/Ws2def.h/header file.
MSDN says Mask parameter also gets set on failure.
if(MaskLength <= 32) return ERROR_INVALID_PARAMETER;
Maybe we should check MaskLength lower bound as well?
I haven't really look into it yet because even MSDN can be wrong. But I suggest you add a test to verify. If you're sending the patch on others behalf and you're not familiar with how to write a test, contact original author.
Zhiyi Zhang
On 3/16/2018 5:02 AM, Uberdaff wrote:
From: Dagfinn Reiakvam dagfinn@reiakvam.no
dlls/iphlpapi/iphlpapi.spec | 2 +- dlls/iphlpapi/iphlpapi_main.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec index b6c9aef..bbd1ed8 100644 --- a/dlls/iphlpapi/iphlpapi.spec +++ b/dlls/iphlpapi/iphlpapi.spec @@ -23,7 +23,7 @@ @ stdcall ConvertInterfaceNameToLuidW( wstr ptr ) #@ stub ConvertInterfacePhysicalAddressToLuid #@ stub ConvertIpv4MaskToLength -#@ stub ConvertLengthToIpv4Mask +@ stdcall ConvertLengthToIpv4Mask( long ptr ) #@ stub ConvertRemoteInterfaceAliasToLuid #@ stub ConvertRemoteInterfaceGuidToLuid #@ stub ConvertRemoteInterfaceIndexToLuid diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 97284ed..891f8f0 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -3223,6 +3223,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid) }
/******************************************************************
- ConvertLengthToIpv4Mask (IPHLPAPI.@)
- */
+DWORD WINAPI ConvertLengthToIpv4Mask(ULONG MaskLength, PULONG Mask) +{
- if(MaskLength <= 32)
return ERROR_INVALID_PARAMETER;
- *Mask = 0xffffffff << ( 32 - MaskLength );
- return NO_ERROR;
+}
+/******************************************************************
- if_nametoindex (IPHLPAPI.@)
*/ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
On Fri, Mar 16, 2018 at 04:21:15PM +0800, Zhiyi Zhang wrote:
Hi Uberdaff, On success, ConvertLengthToIpv4Mask returns NO_ERROR. Any nonzero return value indicates failure and the Mask parameter is set to INADDR_NONE defined in the Ws2def.h header file. MSDN says Mask parameter also gets set on failure.
if(MaskLength <= 32) return ERROR_INVALID_PARAMETER;
Maybe we should check MaskLength lower bound as well?
I haven't really look into it yet because even MSDN can be wrong. But I suggest you add a test to verify. If you're sending the patch on others behalf and you're not familiar with how to write a test, contact original author.
Yes, you should definitely add some tests. They will show that your implementation isn't correct.
Also, change the commit message to: iphlpapi: Add support for ConvertLengthToIpv4Mask().
and add the prototype to netioapi.h
Huw.
Hi Zhiyi,
I must have overlooked setting Mask on failure. I can fix that.
I was considering setting a lower bound as well, but I was uncertain what that bound would be. The MaskLength is unsigned, negative numbers at least are not possible.
And I should defiantly write some tests, since I already see that I screwed up on the INVALID_PARAMETER check (used '<=' not '>=').
I will fix my mistakes and come back with a better patch :)
Uberdaff
On 16. mars 2018 09:21, Zhiyi Zhang wrote:
Hi Uberdaff,
On success,*ConvertLengthToIpv4Mask*returns*NO_ERROR*. Any nonzero return value indicates failure and the/Mask/parameter is set to*INADDR_NONE*defined in the/Ws2def.h/header file.
MSDN says Mask parameter also gets set on failure.
if(MaskLength <= 32) return ERROR_INVALID_PARAMETER;
Maybe we should check MaskLength lower bound as well?
I haven't really look into it yet because even MSDN can be wrong. But I suggest you add a test to verify. If you're sending the patch on others behalf and you're not familiar with how to write a test, contact original author.
Zhiyi Zhang
On 3/16/2018 5:02 AM, Uberdaff wrote:
From: Dagfinn Reiakvamdagfinn@reiakvam.no
dlls/iphlpapi/iphlpapi.spec | 2 +- dlls/iphlpapi/iphlpapi_main.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec index b6c9aef..bbd1ed8 100644 --- a/dlls/iphlpapi/iphlpapi.spec +++ b/dlls/iphlpapi/iphlpapi.spec @@ -23,7 +23,7 @@ @ stdcall ConvertInterfaceNameToLuidW( wstr ptr ) #@ stub ConvertInterfacePhysicalAddressToLuid #@ stub ConvertIpv4MaskToLength -#@ stub ConvertLengthToIpv4Mask +@ stdcall ConvertLengthToIpv4Mask( long ptr ) #@ stub ConvertRemoteInterfaceAliasToLuid #@ stub ConvertRemoteInterfaceGuidToLuid #@ stub ConvertRemoteInterfaceIndexToLuid diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 97284ed..891f8f0 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -3223,6 +3223,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid) }
/******************************************************************
- ConvertLengthToIpv4Mask (IPHLPAPI.@)
- */
+DWORD WINAPI ConvertLengthToIpv4Mask(ULONG MaskLength, PULONG Mask) +{
- if(MaskLength <= 32)
return ERROR_INVALID_PARAMETER;
- *Mask = 0xffffffff << ( 32 - MaskLength );
- return NO_ERROR;
+}
+/******************************************************************
- if_nametoindex (IPHLPAPI.@)
*/ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
On 15. mars 2018 22:02, Uberdaff wrote:
From: Dagfinn Reiakvam dagfinn@reiakvam.no
dlls/iphlpapi/iphlpapi.spec | 2 +- dlls/iphlpapi/iphlpapi_main.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec index b6c9aef..bbd1ed8 100644 --- a/dlls/iphlpapi/iphlpapi.spec +++ b/dlls/iphlpapi/iphlpapi.spec @@ -23,7 +23,7 @@ @ stdcall ConvertInterfaceNameToLuidW( wstr ptr ) #@ stub ConvertInterfacePhysicalAddressToLuid #@ stub ConvertIpv4MaskToLength -#@ stub ConvertLengthToIpv4Mask +@ stdcall ConvertLengthToIpv4Mask( long ptr ) #@ stub ConvertRemoteInterfaceAliasToLuid #@ stub ConvertRemoteInterfaceGuidToLuid #@ stub ConvertRemoteInterfaceIndexToLuid diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 97284ed..891f8f0 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -3223,6 +3223,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid) }
/******************************************************************
- ConvertLengthToIpv4Mask (IPHLPAPI.@)
- */
+DWORD WINAPI ConvertLengthToIpv4Mask(ULONG MaskLength, PULONG Mask) +{
- if(MaskLength <= 32)
return ERROR_INVALID_PARAMETER;
- *Mask = 0xffffffff << ( 32 - MaskLength );
- return NO_ERROR;
+}
+/******************************************************************
- if_nametoindex (IPHLPAPI.@)
*/ IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
This patch can be rejected. Sorry for any inconvenience.
A new patch has been submitted.
- Dagfinn