diff options
Diffstat (limited to 'pcap-win32.c')
-rw-r--r-- | pcap-win32.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/pcap-win32.c b/pcap-win32.c index a6a57a3e..dd3cfcc0 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -254,7 +254,7 @@ pcap_getevent_win32(pcap_t *p) } static int -pcap_oid_get_request_win32(pcap_t *p, bpf_u_int32 oid, void *data, size_t len) +pcap_oid_get_request_win32(pcap_t *p, bpf_u_int32 oid, void *data, size_t *len) { PACKET_OID_DATA *oid_data_arg; char errbuf[PCAP_ERRBUF_SIZE+1]; @@ -266,7 +266,7 @@ pcap_oid_get_request_win32(pcap_t *p, bpf_u_int32 oid, void *data, size_t len) * 1-byte data array at the end, standing in for the variable-length * data that's actually there. */ - oid_data_arg = malloc(sizeof (PACKET_OID_DATA) + len); + oid_data_arg = malloc(sizeof (PACKET_OID_DATA) + *len); if (oid_data_arg == NULL) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Couldn't allocate argument buffer for PacketRequest"); @@ -277,7 +277,7 @@ pcap_oid_get_request_win32(pcap_t *p, bpf_u_int32 oid, void *data, size_t len) * No need to copy the data - we're doing a fetch. */ oid_data_arg->Oid = oid; - oid_data_arg->Length = (ULONG)len; /* XXX - check for ridiculously large value? */ + oid_data_arg->Length = (ULONG)(*len); /* XXX - check for ridiculously large value? */ if (!PacketRequest(p->adapter, FALSE, oid_data_arg)) { pcap_win32_err_to_str(GetLastError(), errbuf); pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, @@ -287,16 +287,21 @@ pcap_oid_get_request_win32(pcap_t *p, bpf_u_int32 oid, void *data, size_t len) } /* + * Get the length actually supplied. + */ + *len = oid_data_arg->Length; + + /* * Copy back the data we fetched. */ - memcpy(data, oid_data_arg->Data, len); + memcpy(data, oid_data_arg->Data, *len); free(oid_data_arg); return (0); } static int pcap_oid_set_request_win32(pcap_t *p, bpf_u_int32 oid, const void *data, - size_t len) + size_t *len) { PACKET_OID_DATA *oid_data_arg; char errbuf[PCAP_ERRBUF_SIZE+1]; @@ -308,7 +313,7 @@ pcap_oid_set_request_win32(pcap_t *p, bpf_u_int32 oid, const void *data, * 1-byte data array at the end, standing in for the variable-length * data that's actually there. */ - oid_data_arg = malloc(sizeof (PACKET_OID_DATA) + len); + oid_data_arg = malloc(sizeof (PACKET_OID_DATA) + *len); if (oid_data_arg == NULL) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Couldn't allocate argument buffer for PacketRequest"); @@ -316,8 +321,8 @@ pcap_oid_set_request_win32(pcap_t *p, bpf_u_int32 oid, const void *data, } oid_data_arg->Oid = oid; - oid_data_arg->Length = (ULONG)len; /* XXX - check for ridiculously large value? */ - memcpy(oid_data_arg->Data, data, len); + oid_data_arg->Length = (ULONG)(*len); /* XXX - check for ridiculously large value? */ + memcpy(oid_data_arg->Data, data, *len); if (!PacketRequest(p->adapter, TRUE, oid_data_arg)) { pcap_win32_err_to_str(GetLastError(), errbuf); pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, @@ -327,6 +332,11 @@ pcap_oid_set_request_win32(pcap_t *p, bpf_u_int32 oid, const void *data, } /* + * Get the length actually copied. + */ + *len = oid_data_arg->Length; + + /* * No need to copy the data - we're doing a set. */ free(oid_data_arg); |