diff options
author | Alin Serdean <aserdean@cloudbasesolutions.com> | 2017-07-14 04:40:57 +0000 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-08-02 11:32:16 -0700 |
commit | 3630a2f321226bce0306c6a8834812a0dd4dc88f (patch) | |
tree | a92e3ceddad5d3b3152b1d35877e1379e1bc4f55 /datapath-windows | |
parent | 1c5875f7d9d7dd93aa319265fdeaf971c871b010 (diff) | |
download | openvswitch-3630a2f321226bce0306c6a8834812a0dd4dc88f.tar.gz |
datapath-windows: Check return status when using APIs
Check the return status of `ConvertInterfaceLuidToAlias` and `RtlStringCbLengthW`
and treat them accordingly.
Also remove unneeded initialization for `interfaceName`.
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Shashank Ram <rams@vmware.com>
Diffstat (limited to 'datapath-windows')
-rw-r--r-- | datapath-windows/ovsext/IpHelper.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/datapath-windows/ovsext/IpHelper.c b/datapath-windows/ovsext/IpHelper.c index 3021c3c6a..548833d2a 100644 --- a/datapath-windows/ovsext/IpHelper.c +++ b/datapath-windows/ovsext/IpHelper.c @@ -369,7 +369,7 @@ OvsGetRoute(SOCKADDR_INET *destinationAddress, SOCKADDR_INET crtSrcAddr = { 0 }; MIB_IPFORWARD_ROW2 crtRoute = { 0 }; POVS_IPHELPER_INSTANCE crtInstance = NULL; - WCHAR interfaceName[IF_MAX_STRING_SIZE + 1] = { 0 }; + WCHAR interfaceName[IF_MAX_STRING_SIZE + 1]; crtInstance = CONTAINING_RECORD(link, OVS_IPHELPER_INSTANCE, link); @@ -394,11 +394,16 @@ OvsGetRoute(SOCKADDR_INET *destinationAddress, RtlCopyMemory(route, &crtRoute, sizeof(*route)); *instance = crtInstance; - ConvertInterfaceLuidToAlias(&crtInstance->internalRow.InterfaceLuid, - interfaceName, IF_MAX_STRING_SIZE + 1); - RtlStringCbLengthW(interfaceName, IF_MAX_STRING_SIZE, &len); + status = + ConvertInterfaceLuidToAlias(&crtInstance->internalRow.InterfaceLuid, + interfaceName, + IF_MAX_STRING_SIZE + 1); + if (NT_SUCCESS(status)) { + status = RtlStringCbLengthW(interfaceName, IF_MAX_STRING_SIZE, + &len); + } - if (gOvsSwitchContext != NULL) { + if (gOvsSwitchContext != NULL && NT_SUCCESS(status)) { NdisAcquireRWLockRead(gOvsSwitchContext->dispatchLock, &lockState, 0); *vport = OvsFindVportByHvNameW(gOvsSwitchContext, @@ -608,11 +613,11 @@ OvsAddIpInterfaceNotification(PMIB_IPINTERFACE_ROW ipRow) InitializeListHead(&instance->link); ExInitializeResourceLite(&instance->lock); - WCHAR interfaceName[IF_MAX_STRING_SIZE + 1] = { 0 }; + WCHAR interfaceName[IF_MAX_STRING_SIZE + 1]; status = ConvertInterfaceLuidToAlias(&ipRow->InterfaceLuid, interfaceName, IF_MAX_STRING_SIZE + 1); - if (gOvsSwitchContext == NULL) { + if (gOvsSwitchContext == NULL || !NT_SUCCESS(status)) { goto error; } NdisAcquireRWLockRead(gOvsSwitchContext->dispatchLock, &lockState, 0); |