diff options
-rw-r--r-- | pcap-int.h | 4 | ||||
-rw-r--r-- | pcap-tc.c | 8 | ||||
-rw-r--r-- | pcap-win32.c | 26 | ||||
-rw-r--r-- | pcap.c | 8 | ||||
-rw-r--r-- | pcap/pcap.h | 4 | ||||
-rw-r--r-- | savefile.c | 4 |
6 files changed, 32 insertions, 22 deletions
@@ -134,8 +134,8 @@ typedef int (*setbuff_op_t)(pcap_t *, int); typedef int (*setmode_op_t)(pcap_t *, int); typedef int (*setmintocopy_op_t)(pcap_t *, int); typedef HANDLE (*getevent_op_t)(pcap_t *); -typedef int (*oid_get_request_op_t)(pcap_t *, bpf_u_int32, void *, size_t); -typedef int (*oid_set_request_op_t)(pcap_t *, bpf_u_int32, const void *, size_t); +typedef int (*oid_get_request_op_t)(pcap_t *, bpf_u_int32, void *, size_t *); +typedef int (*oid_set_request_op_t)(pcap_t *, bpf_u_int32, const void *, size_t *); typedef u_int (*sendqueue_transmit_op_t)(pcap_t *, pcap_send_queue *, int); typedef int (*setuserbuffer_op_t)(pcap_t *, int); typedef int (*live_dump_op_t)(pcap_t *, char *, int, int); @@ -133,8 +133,8 @@ static int TcSetBuff(pcap_t *p, int dim); static int TcSetMode(pcap_t *p, int mode); static int TcSetMinToCopy(pcap_t *p, int size); static HANDLE TcGetReceiveWaitHandle(pcap_t *p); -static int TcOidGetRequest(pcap_t *p, bpf_u_int32 oid, void *data, size_t len); -static int TcOidSetRequest(pcap_t *p, bpf_u_int32 oid, const void *data, size_t len); +static int TcOidGetRequest(pcap_t *p, bpf_u_int32 oid, void *data, size_t *len); +static int TcOidSetRequest(pcap_t *p, bpf_u_int32 oid, const void *data, size_t *len); static u_int TcSendqueueTransmit(pcap_t *p, pcap_send_queue *queue, int sync); static int TcSetUserBuffer(pcap_t *p, int size); static int TcLiveDump(pcap_t *p, char *filename, int maxsize, int maxpacks); @@ -1228,7 +1228,7 @@ TcGetReceiveWaitHandle(pcap_t *p) } static int -TcOidGetRequest(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, size_t len _U_) +TcOidGetRequest(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, size_t *len _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "An OID get request cannot be performed on a TurboCap device"); @@ -1237,7 +1237,7 @@ TcOidGetRequest(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, size_t len _U_) static int TcOidSetRequest(pcap_t *p, bpf_u_int32 oid _U_, const void *data _U_, - size_t len _U_) + size_t *len _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "An OID set request cannot be performed on a TurboCap device"); 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); @@ -1726,14 +1726,14 @@ pcap_getevent_dead(pcap_t *p) } int -pcap_oid_get_request(pcap_t *p, bpf_u_int32 oid, void *data, size_t len) +pcap_oid_get_request(pcap_t *p, bpf_u_int32 oid, void *data, size_t *len) { return (p->oid_get_request_op(p, oid, data, len)); } static int pcap_oid_get_request_dead(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, - size_t len _U_) + size_t *len _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "An OID get request cannot be performed on a pcap_open_dead pcap_t"); @@ -1741,14 +1741,14 @@ pcap_oid_get_request_dead(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, } int -pcap_oid_set_request(pcap_t *p, bpf_u_int32 oid, const void *data, size_t len) +pcap_oid_set_request(pcap_t *p, bpf_u_int32 oid, const void *data, size_t *len) { return (p->oid_set_request_op(p, oid, data, len)); } static int pcap_oid_set_request_dead(pcap_t *p, bpf_u_int32 oid _U_, const void *data _U_, - size_t len _U_) + size_t *len _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "An OID set request cannot be performed on a pcap_open_dead pcap_t"); diff --git a/pcap/pcap.h b/pcap/pcap.h index 126c0c6a..b5d50b8e 100644 --- a/pcap/pcap.h +++ b/pcap/pcap.h @@ -479,8 +479,8 @@ PCAP_API void bpf_dump(const struct bpf_program *, int); PCAP_API HANDLE pcap_getevent(pcap_t *p); - PCAP_API int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t); - PCAP_API int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t); + PCAP_API int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t *); + PCAP_API int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t *); PCAP_API pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); @@ -169,7 +169,7 @@ sf_getevent(pcap_t *pcap) static int sf_oid_get_request(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, - size_t len _U_) + size_t *len _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "An OID get request cannot be performed on a file"); @@ -178,7 +178,7 @@ sf_oid_get_request(pcap_t *p, bpf_u_int32 oid _U_, void *data _U_, static int sf_oid_set_request(pcap_t *p, bpf_u_int32 oid _U_, const void *data _U_, - size_t len _U_) + size_t *len _U_) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "An OID set request cannot be performed on a file"); |