Juan Lang : inetmib1: Copy an IP net row' s physical address using a type-specific helper function, rather than using a generic helper function which made an invalid alignment assumption .

Alexandre Julliard julliard at winehq.org
Wed Dec 9 10:46:26 CST 2009


Module: wine
Branch: master
Commit: 960a1a9ab7c7f8841fe0db72356823206e970cf0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=960a1a9ab7c7f8841fe0db72356823206e970cf0

Author: Juan Lang <juan.lang at gmail.com>
Date:   Mon Dec  7 13:37:29 2009 -0800

inetmib1: Copy an IP net row's physical address using a type-specific helper function, rather than using a generic helper function which made an invalid alignment assumption.

---

 dlls/inetmib1/main.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c
index f11bc3b..9aef4d5 100644
--- a/dlls/inetmib1/main.c
+++ b/dlls/inetmib1/main.c
@@ -50,14 +50,6 @@ static void setStringValue(AsnAny *value, BYTE type, DWORD len, BYTE *str)
     SnmpUtilAsnAnyCpy(value, &strValue);
 }
 
-static DWORD copyLengthPrecededString(AsnAny *value, void *src)
-{
-    DWORD len = *(DWORD *)src;
-
-    setStringValue(value, ASN_OCTETSTRING, len, (BYTE *)src + sizeof(DWORD));
-    return SNMP_ERRORSTATUS_NOERROR;
-}
-
 typedef DWORD (*copyValueFunc)(AsnAny *value, void *src);
 
 struct structToAsnValue
@@ -919,9 +911,18 @@ static BOOL mib2IpRouteQuery(BYTE bPduType, SnmpVarBind *pVarBind,
 static UINT mib2IpNet[] = { 1,3,6,1,2,1,4,22,1 };
 static PMIB_IPNETTABLE ipNetTable;
 
+static DWORD copyIpNetPhysAddr(AsnAny *value, void *src)
+{
+    PMIB_IPNETROW row = (PMIB_IPNETROW)((BYTE *)src - FIELD_OFFSET(MIB_IPNETROW,
+                                        dwPhysAddrLen));
+
+    setStringValue(value, ASN_OCTETSTRING, row->dwPhysAddrLen, row->bPhysAddr);
+    return SNMP_ERRORSTATUS_NOERROR;
+}
+
 static struct structToAsnValue mib2IpNetMap[] = {
     { FIELD_OFFSET(MIB_IPNETROW, dwIndex), copyInt },
-    { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyLengthPrecededString },
+    { FIELD_OFFSET(MIB_IPNETROW, dwPhysAddrLen), copyIpNetPhysAddr },
     { FIELD_OFFSET(MIB_IPNETROW, dwAddr), copyIpAddr },
     { FIELD_OFFSET(MIB_IPNETROW, dwType), copyInt },
 };




More information about the wine-cvs mailing list