X-Git-Url: http://git.samba.org/samba.git/?p=obnox%2Fwireshark%2Fwip.git;a=blobdiff_plain;f=capture_wpcap_packet.c;h=d26da5f8f4fdfb59f8d89d5186a47be468533db3;hp=d055a72d5904c4bb79318f2ea6a2f652deec21cb;hb=403cd88b4a708e02131597cc7c9b5f8bfd384b9c;hpb=9db56cc7a54f56feca2aa7607b41a7a4ef15df7a diff --git a/capture_wpcap_packet.c b/capture_wpcap_packet.c index d055a72d59..d26da5f8f4 100644 --- a/capture_wpcap_packet.c +++ b/capture_wpcap_packet.c @@ -44,10 +44,14 @@ -#ifndef HAVE_SOCKADDR_STORAGE -/* packet32.h requires sockaddr_storage (usually defined in Platform SDK) +/* packet32.h requires sockaddr_storage + * wether sockaddr_storage is defined or not depends on the Platform SDK + * version installed. The only one not defining it is the SDK that comes + * with MSVC 6.0 (WINVER 0x0400). + * * copied from RFC2553 (and slightly modified because of datatypes) ... * XXX - defined more than once, move this to a header file */ +#if (WINVER <= 0x0400) && defined(_MSC_VER) typedef unsigned short eth_sa_family_t; /* @@ -63,12 +67,6 @@ typedef unsigned short eth_sa_family_t; #define ETH_SS_PAD2SIZE (ETH_SS_MAXSIZE - (sizeof (eth_sa_family_t) + \ ETH_SS_PAD1SIZE + ETH_SS_ALIGNSIZE)) -/* sockaddr_storage problem with different MSVC versions - * - MSVC 6 (1200) doesn't define this - * - MSVC 7 (1300) unknown - * - MSVC 8 (1400) does */ -/* we might need to tweak this #if, see version_info for _MSC_VER values */ -#if _MSC_VER < 1400 struct sockaddr_storage { eth_sa_family_t __ss_family; /* address family */ /* Following fields are implementation specific */ @@ -84,8 +82,7 @@ struct sockaddr_storage { /* __ss_pad1, __ss_align fields is 112 */ }; /* ... copied from RFC2553 */ -#endif /* _MSC_VER */ -#endif +#endif /* WINVER */ #include @@ -241,9 +238,10 @@ wpcap_packet_request(void *adapter, ULONG Oid, int set, char *value, unsigned in return 0; } + /* get a buffer suitable for PacketRequest() */ OidData=GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT,IoCtlBufferLength); if (OidData == NULL) { - g_warning("packet_link_status failed\n"); + g_warning("GlobalAllocPtr failed for %u\n", IoCtlBufferLength); return 0; } @@ -254,9 +252,15 @@ wpcap_packet_request(void *adapter, ULONG Oid, int set, char *value, unsigned in Status = p_PacketRequest(adapter, set, OidData); if(Status) { - g_assert(OidData->Length <= *length); - memcpy(value, OidData->Data, OidData->Length); - *length = OidData->Length; + if(OidData->Length <= *length) { + /* copy value from driver */ + memcpy(value, OidData->Data, OidData->Length); + *length = OidData->Length; + } else { + /* the driver returned a value that is longer than expected (and longer than the given buffer) */ + g_warning("returned oid too long, Oid: 0x%x OidLen:%u MaxLen:%u", Oid, OidData->Length, *length); + Status = FALSE; + } } GlobalFreePtr (OidData);