[ofw] [PATCH 5/12] nd2/adapter: move up check against query length

Hefty, Sean sean.hefty at intel.com
Tue Jul 27 00:57:49 PDT 2010


Check that the length of pInfo is large enough before
dereferencing it.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
 trunk/ulp/netdirect2/user/nd_adapter.cpp |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/trunk/ulp/netdirect2/user/nd_adapter.cpp b/trunk/ulp/netdirect2/user/nd_adapter.cpp
index 34e9fc7..55fba91 100644
--- a/trunk/ulp/netdirect2/user/nd_adapter.cpp
+++ b/trunk/ulp/netdirect2/user/nd_adapter.cpp
@@ -116,16 +116,17 @@ Query(ND_ADAPTER_INFO* pInfo, SIZE_T* pcbInfo)
 	WV_DEVICE_ATTRIBUTES attr;
 	HRESULT hr;
 
-	if (pInfo != NULL && pInfo->InfoVersion != 1) {
-		return ND_NOT_SUPPORTED;
-	}
-
 	if (*pcbInfo < sizeof(ND_ADAPTER_INFO)) {
 		hr = ND_BUFFER_OVERFLOW;
 		goto out;
 	}
 
-	hr = m_pWvDevice->Query(&attr);
+	if (pInfo != NULL && pInfo->InfoVersion != 1) {
+		hr = ND_NOT_SUPPORTED;
+		goto out;
+	}
+
+	hr = NDConvertWVStatus(m_pWvDevice->Query(&attr));
 	if (FAILED(hr)) {
 		goto out;
 	}
@@ -157,7 +158,7 @@ Query(ND_ADAPTER_INFO* pInfo, SIZE_T* pcbInfo)
 
 out:
 	*pcbInfo = sizeof(ND_ADAPTER_INFO);
-	return NDConvertWVStatus(hr);
+	return hr;
 }
 
 STDMETHODIMP CNDAdapter::




More information about the ofw mailing list