pcap: fix buffer size validation logic

pull/3534/head
Victor Julien 7 years ago
parent 9c2c258f2b
commit 22c7be26c4

@ -99,8 +99,14 @@ static void *ParsePcapConfig(const char *iface)
aconf->buffer_size = 0;
/* If set command line option has precedence over config */
if ((ConfGetInt("pcap.buffer-size", &value)) == 1) {
SCLogInfo("Pcap will use %d buffer size", (int)value);
aconf->buffer_size = value;
if (value >= 0 && value <= INT_MAX) {
SCLogInfo("Pcap will use %d buffer size", (int)value);
aconf->buffer_size = value;
} else {
SCLogWarning(SC_ERR_INVALID_ARGUMENT, "pcap.buffer-size "
"value of %"PRIiMAX" is invalid. Valid range is "
"0-2147483647", value);
}
}
aconf->checksum_mode = CHECKSUM_VALIDATION_AUTO;

@ -408,9 +408,8 @@ TmEcode ReceivePcapThreadInit(ThreadVars *tv, const void *initdata, void **data)
}
#ifdef HAVE_PCAP_SET_BUFF
ptv->pcap_buffer_size = pcapconfig->buffer_size;
if (ptv->pcap_buffer_size >= 0 && ptv->pcap_buffer_size <= INT_MAX) {
if (ptv->pcap_buffer_size > 0)
SCLogInfo("Going to use pcap buffer size of %" PRId32 "", ptv->pcap_buffer_size);
if (ptv->pcap_buffer_size > 0) {
SCLogInfo("Going to use pcap buffer size of %" PRId32 "", ptv->pcap_buffer_size);
int pcap_set_buffer_size_r = pcap_set_buffer_size(ptv->pcap_handle,ptv->pcap_buffer_size);
//printf("ReceivePcapThreadInit: pcap_set_timeout(%p) returned %" PRId32 "\n", ptv->pcap_handle, pcap_set_buffer_size_r);

Loading…
Cancel
Save