diff mbox series

[ovs-dev,v2,3/7] datapath-windows: Vport check RtlStringCbLengthW return value

Message ID 20171106153339.10100-3-aserdean@ovn.org
State Accepted
Headers show
Series [ovs-dev,v2,1/7] datapath-windows: Use only non executable memory | expand

Commit Message

Alin-Gabriel Serdean Nov. 6, 2017, 3:33 p.m. UTC
From: Alin Serdean <aserdean@cloudbasesolutions.com>

The result of `RtlStringCbLengthW` is not currently checked and triggers
a warning using the WDK 8.1 static analysis.

This patch treats the result of `RtlStringCbLengthW`.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
---
v2: s/Fail/Failed. Suggested by: Shashank Ram rams@vmware.com
---
 datapath-windows/ovsext/Vport.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Shashank Ram Nov. 7, 2017, 1:47 a.m. UTC | #1
From: Alin Serdean <aserdean@cloudbasesolutions.com>
>
> The result of `RtlStringCbLengthW` is not currently checked and triggers
> a warning using the WDK 8.1 static analysis.
>
> This patch treats the result of `RtlStringCbLengthW`.
>
> Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
> ---
> v2: s/Fail/Failed. Suggested by: Shashank Ram rams@vmware.com
> ---

Acked-by: Shashank Ram <shashank08@gmail.com>
diff mbox series

Patch

diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index 075f419..7cf2497 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -1144,8 +1144,13 @@  GetNICAlias(PNDIS_SWITCH_NIC_PARAMETERS nicParam,
         if (status == STATUS_SUCCESS) {
             RtlStringCbPrintfW(portFriendlyName->String,
                                IF_MAX_STRING_SIZE, L"%s", interfaceName);
-            RtlStringCbLengthW(portFriendlyName->String, IF_MAX_STRING_SIZE,
-                               &len);
+            status = RtlStringCbLengthW(portFriendlyName->String,
+                                        IF_MAX_STRING_SIZE, &len);
+            if (!NT_SUCCESS(status)) {
+                OVS_LOG_ERROR("Failed to get the length of the string,"
+                              "status: %x", status);
+                return status;
+            }
             portFriendlyName->Length = (USHORT)len;
         } else {
             OVS_LOG_ERROR("Fail to convert interface LUID to alias, status: %x",