[ovs-dev,v2,5/7] datapath-windows: Fix static analysis warnings in OvsGetTcpPayloadLength

Message ID 20171106153339.10100-5-aserdean@ovn.org
State New
Headers show
Series
  • [ovs-dev,v2,1/7] datapath-windows: Use only non executable memory
Related show

Commit Message

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

This fixes the static code analysis over the function
'OvsGetTcpPayloadLength'.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
---
v2: No change.
---
 datapath-windows/ovsext/Conntrack.h | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Comments

Shashank Ram Nov. 7, 2017, 2:14 a.m. | #1
On Mon, Nov 6, 2017 at 7:33 AM, Alin Gabriel Serdean <aserdean@ovn.org>
wrote:

> From: Alin Serdean <aserdean@cloudbasesolutions.com>
>
> This fixes the static code analysis over the function
> 'OvsGetTcpPayloadLength'.
>
> Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
> ---
> v2: No change.
> ---
>
Acked-by: Shashank Ram <shashank08@gmail.com>

Patch

diff --git a/datapath-windows/ovsext/Conntrack.h b/datapath-windows/ovsext/Conntrack.h
index be5f34d..ef1fe21 100644
--- a/datapath-windows/ovsext/Conntrack.h
+++ b/datapath-windows/ovsext/Conntrack.h
@@ -157,20 +157,17 @@  static __inline UINT32
 OvsGetTcpPayloadLength(PNET_BUFFER_LIST nbl)
 {
     IPHdr *ipHdr;
-    char *ipBuf[sizeof(IPHdr)];
-    PNET_BUFFER curNb;
-    curNb = NET_BUFFER_LIST_FIRST_NB(nbl);
-    UINT32 hdrLen = sizeof(EthHdr);
-    NdisAdvanceNetBufferDataStart(curNb, hdrLen, FALSE, NULL);
-    ipHdr = NdisGetDataBuffer(curNb, sizeof *ipHdr, (PVOID) &ipBuf,
-                              1 /*no align*/, 0);
+    TCPHdr *tcp;
+    char *ipBuf[sizeof(EthHdr) + sizeof(IPHdr) + sizeof(TCPHdr)];
+
+    ipHdr = NdisGetDataBuffer(NET_BUFFER_LIST_FIRST_NB(nbl), sizeof *ipBuf,
+                              (PVOID)&ipBuf, 1 /*no align*/, 0);
     if (ipHdr == NULL) {
-        NdisRetreatNetBufferDataStart(curNb, hdrLen, 0, NULL);
         return 0;
     }
 
-    TCPHdr *tcp = (TCPHdr *)((PCHAR)ipHdr + ipHdr->ihl * 4);
-    NdisRetreatNetBufferDataStart(curNb, hdrLen, 0, NULL);
+    ipHdr = (IPHdr *)((PCHAR)ipHdr + sizeof(EthHdr));
+    tcp = (TCPHdr *)((PCHAR)ipHdr + ipHdr->ihl * 4);
 
     return (ntohs(ipHdr->tot_len) - (ipHdr->ihl * 4) - (TCP_HDR_LEN(tcp)));
 }