2013-09-20 15:13:12 +00:00
|
|
|
---
|
|
|
|
configure.in | 4 +++-
|
|
|
|
fad-gifc.c | 2 +-
|
|
|
|
fad-glifc.c | 4 ++--
|
|
|
|
inet.c | 4 ++--
|
|
|
|
nametoaddr.c | 2 +-
|
|
|
|
pcap-bt-linux.c | 6 +++---
|
|
|
|
pcap-can-linux.c | 4 ++--
|
|
|
|
pcap-canusb-linux.c | 3 ++-
|
|
|
|
pcap-linux.c | 16 ++++++++--------
|
|
|
|
pcap-netfilter-linux.c | 4 ++--
|
|
|
|
pcap-nit.c | 2 +-
|
|
|
|
pcap-sita.c | 2 +-
|
|
|
|
pcap-snit.c | 4 ++--
|
|
|
|
pcap-snoop.c | 2 +-
|
|
|
|
pcap-usb-linux.c | 12 ++++++------
|
|
|
|
savefile.c | 2 +-
|
|
|
|
sf-pcap.c | 2 +-
|
|
|
|
17 files changed, 39 insertions(+), 36 deletions(-)
|
|
|
|
|
|
|
|
Index: libpcap-1.4.0/configure.in
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/configure.in 2013-03-25 14:51:40.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/configure.in 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -22,7 +22,9 @@ AC_INIT(pcap.c)
|
|
|
|
AC_CANONICAL_SYSTEM
|
|
|
|
|
|
|
|
AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
|
|
|
|
-AC_PROG_CC
|
|
|
|
+AC_PROG_CC_STDC
|
|
|
|
+AC_USE_SYSTEM_EXTENSIONS
|
|
|
|
+AC_SYS_LARGEFILE
|
|
|
|
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
|
|
|
|
AC_LBL_SHLIBS_INIT
|
|
|
|
AC_LBL_C_INLINE
|
|
|
|
Index: libpcap-1.4.0/fad-gifc.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/fad-gifc.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/fad-gifc.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -157,7 +157,7 @@ pcap_findalldevs_interfaces(pcap_if_t **
|
|
|
|
/*
|
|
|
|
* Create a socket from which to fetch the list of interfaces.
|
|
|
|
*/
|
|
|
|
- fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (fd < 0) {
|
|
|
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
|
|
|
Index: libpcap-1.4.0/fad-glifc.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/fad-glifc.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/fad-glifc.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -100,7 +100,7 @@ pcap_findalldevs_interfaces(pcap_if_t **
|
|
|
|
* Create a socket from which to fetch the list of interfaces,
|
|
|
|
* and from which to fetch IPv4 information.
|
|
|
|
*/
|
|
|
|
- fd4 = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
+ fd4 = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (fd4 < 0) {
|
|
|
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
|
|
|
@@ -110,7 +110,7 @@ pcap_findalldevs_interfaces(pcap_if_t **
|
|
|
|
/*
|
|
|
|
* Create a socket from which to fetch IPv6 information.
|
|
|
|
*/
|
|
|
|
- fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
|
|
|
|
+ fd6 = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (fd6 < 0) {
|
|
|
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
|
|
|
Index: libpcap-1.4.0/inet.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/inet.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/inet.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -430,7 +430,7 @@ add_addr_to_iflist(pcap_if_t **alldevs,
|
|
|
|
*/
|
|
|
|
memset(&ifrdesc, 0, sizeof ifrdesc);
|
|
|
|
strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
|
|
|
|
- s = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
+ s = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (s >= 0) {
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
/*
|
|
|
|
@@ -745,7 +745,7 @@ pcap_lookupnet(device, netp, maskp, errb
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (fd < 0) {
|
|
|
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
|
|
|
|
pcap_strerror(errno));
|
|
|
|
Index: libpcap-1.4.0/nametoaddr.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/nametoaddr.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/nametoaddr.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -441,7 +441,7 @@ pcap_ether_hostton(const char *name)
|
|
|
|
static int init = 0;
|
|
|
|
|
|
|
|
if (!init) {
|
|
|
|
- fp = fopen(PCAP_ETHERS_FILE, "r");
|
|
|
|
+ fp = fopen(PCAP_ETHERS_FILE, "re");
|
|
|
|
++init;
|
|
|
|
if (fp == NULL)
|
|
|
|
return (NULL);
|
|
|
|
Index: libpcap-1.4.0/pcap-bt-linux.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-bt-linux.c 2013-03-25 14:51:40.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-bt-linux.c 2013-09-13 20:19:44.000000000 +0100
|
|
|
|
@@ -79,7 +79,7 @@ bt_findalldevs(pcap_if_t **alldevsp, cha
|
|
|
|
int i, sock;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
- sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
|
|
|
+ sock = socket(AF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, BTPROTO_HCI);
|
|
|
|
if (sock < 0)
|
|
|
|
{
|
|
|
|
/* if bluetooth is not supported this this is not fatal*/
|
|
|
|
@@ -211,7 +211,7 @@ bt_activate(pcap_t* handle)
|
|
|
|
handle->md.ifindex = dev_id;
|
|
|
|
|
|
|
|
/* Create HCI socket */
|
|
|
|
- handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
|
|
|
+ handle->fd = socket(AF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, BTPROTO_HCI);
|
|
|
|
if (handle->fd < 0) {
|
|
|
|
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"Can't create raw socket: %s", strerror(errno));
|
|
|
|
@@ -315,7 +315,7 @@ bt_read_linux(pcap_t *handle, int max_pa
|
|
|
|
|
|
|
|
/* ignore interrupt system call error */
|
|
|
|
do {
|
|
|
|
- ret = recvmsg(handle->fd, &msg, 0);
|
|
|
|
+ ret = recvmsg(handle->fd, &msg, MSG_CMSG_CLOEXEC);
|
|
|
|
if (handle->break_loop)
|
|
|
|
{
|
|
|
|
handle->break_loop = 0;
|
|
|
|
Index: libpcap-1.4.0/pcap-can-linux.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-can-linux.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-can-linux.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -153,7 +153,7 @@ can_activate(pcap_t* handle)
|
|
|
|
handle->stats_op = can_stats_linux;
|
|
|
|
|
|
|
|
/* Create socket */
|
|
|
|
- handle->fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
|
|
|
|
+ handle->fd = socket(PF_CAN, SOCK_RAW|SOCK_CLOEXEC, CAN_RAW);
|
|
|
|
if (handle->fd < 0)
|
|
|
|
{
|
|
|
|
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s",
|
|
|
|
@@ -227,7 +227,7 @@ can_read_linux(pcap_t *handle, int max_p
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
- pkth.caplen = recvmsg(handle->fd, &msg, 0);
|
|
|
|
+ pkth.caplen = recvmsg(handle->fd, &msg, MSG_CMSG_CLOEXEC);
|
|
|
|
if (handle->break_loop)
|
|
|
|
{
|
|
|
|
handle->break_loop = 0;
|
|
|
|
Index: libpcap-1.4.0/pcap-canusb-linux.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-canusb-linux.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-canusb-linux.c 2013-09-13 20:21:19.000000000 +0100
|
|
|
|
@@ -36,6 +36,7 @@
|
|
|
|
#include "config.h"
|
2012-08-27 19:38:03 +00:00
|
|
|
#endif
|
2013-09-20 15:13:12 +00:00
|
|
|
|
|
|
|
+#include <pthread.h>
|
|
|
|
#include <libusb-1.0/libusb.h>
|
|
|
|
|
|
|
|
#include "pcap-int.h"
|
|
|
|
@@ -297,7 +298,7 @@ static int canusb_startcapture(struct ca
|
|
|
|
{
|
|
|
|
int pipefd[2];
|
|
|
|
|
|
|
|
- if (pipe(pipefd) == -1)
|
|
|
|
+ if (pipe2(pipefd, O_CLOEXEC) == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
canusb.rdpipe = pipefd[0];
|
|
|
|
Index: libpcap-1.4.0/pcap-linux.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-linux.c 2013-09-13 20:15:43.000000000 +0100
|
|
|
|
+++ libpcap-1.4.0/pcap-linux.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -894,7 +894,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
* (We assume that if we have Wireless Extensions support
|
|
|
|
* we also have PF_PACKET support.)
|
|
|
|
*/
|
|
|
|
- sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
|
|
|
+ sock_fd = socket(PF_PACKET, SOCK_RAW|SOCK_CLOEXEC, htons(ETH_P_ALL));
|
|
|
|
if (sock_fd == -1) {
|
|
|
|
(void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -1422,7 +1422,7 @@ pcap_read_packet(pcap_t *handle, pcap_ha
|
2012-08-27 19:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI)
|
|
|
|
- packet_len = recvmsg(handle->fd, &msg, MSG_TRUNC);
|
|
|
|
+ packet_len = recvmsg(handle->fd, &msg, MSG_TRUNC|MSG_CMSG_CLOEXEC);
|
|
|
|
#else /* defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI) */
|
|
|
|
fromlen = sizeof(from);
|
|
|
|
packet_len = recvfrom(
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -1900,7 +1900,7 @@ scan_sys_class_net(pcap_if_t **devlistp,
|
2012-08-27 19:38:03 +00:00
|
|
|
/*
|
|
|
|
* Create a socket from which to fetch interface information.
|
|
|
|
*/
|
|
|
|
- fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (fd < 0) {
|
|
|
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -2077,7 +2077,7 @@ scan_proc_net_dev(pcap_if_t **devlistp,
|
2012-08-27 19:38:03 +00:00
|
|
|
/*
|
|
|
|
* Create a socket from which to fetch interface information.
|
|
|
|
*/
|
|
|
|
- fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
|
|
|
if (fd < 0) {
|
|
|
|
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -2824,8 +2824,8 @@ activate_new(pcap_t *handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
* try a SOCK_RAW socket for the raw interface.
|
|
|
|
*/
|
|
|
|
sock_fd = is_any_device ?
|
|
|
|
- socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)) :
|
|
|
|
- socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
|
|
|
+ socket(PF_PACKET, SOCK_DGRAM|SOCK_CLOEXEC, htons(ETH_P_ALL)) :
|
|
|
|
+ socket(PF_PACKET, SOCK_RAW|SOCK_CLOEXEC, htons(ETH_P_ALL));
|
|
|
|
|
|
|
|
if (sock_fd == -1) {
|
|
|
|
if (errno == EINVAL || errno == EAFNOSUPPORT) {
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -2941,7 +2941,7 @@ activate_new(pcap_t *handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
"close: %s", pcap_strerror(errno));
|
|
|
|
return PCAP_ERROR;
|
|
|
|
}
|
|
|
|
- sock_fd = socket(PF_PACKET, SOCK_DGRAM,
|
|
|
|
+ sock_fd = socket(PF_PACKET, SOCK_DGRAM|SOCK_CLOEXEC,
|
|
|
|
htons(ETH_P_ALL));
|
|
|
|
if (sock_fd == -1) {
|
|
|
|
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -4988,7 +4988,7 @@ activate_old(pcap_t *handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
|
|
|
|
/* Open the socket */
|
|
|
|
|
|
|
|
- handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
|
|
|
|
+ handle->fd = socket(PF_INET, SOCK_PACKET|SOCK_CLOEXEC, htons(ETH_P_ALL));
|
|
|
|
if (handle->fd == -1) {
|
|
|
|
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
2013-09-20 15:13:12 +00:00
|
|
|
Index: libpcap-1.4.0/pcap-netfilter-linux.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-netfilter-linux.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-netfilter-linux.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -478,7 +478,7 @@ netfilter_activate(pcap_t* handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
handle->stats_op = netfilter_stats_linux;
|
|
|
|
|
|
|
|
/* Create netlink socket */
|
|
|
|
- handle->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);
|
|
|
|
+ handle->fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_NETFILTER);
|
|
|
|
if (handle->fd < 0) {
|
|
|
|
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s", errno, pcap_strerror(errno));
|
|
|
|
return PCAP_ERROR;
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -626,7 +626,7 @@ netfilter_findalldevs(pcap_if_t **alldev
|
2012-08-27 19:38:03 +00:00
|
|
|
pcap_if_t *found_dev = *alldevsp;
|
|
|
|
int sock;
|
|
|
|
|
|
|
|
- sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);
|
|
|
|
+ sock = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_NETFILTER);
|
|
|
|
if (sock < 0) {
|
|
|
|
/* if netlink is not supported this is not fatal */
|
|
|
|
if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)
|
2013-09-20 15:13:12 +00:00
|
|
|
Index: libpcap-1.4.0/pcap-nit.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-nit.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-nit.c 2013-09-13 20:17:59.000000000 +0100
|
2012-08-27 19:38:03 +00:00
|
|
|
@@ -259,7 +259,7 @@ pcap_activate_nit(pcap_t *p)
|
|
|
|
p->snapshot = 96;
|
|
|
|
|
|
|
|
memset(p, 0, sizeof(*p));
|
|
|
|
- p->fd = fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW);
|
|
|
|
+ p->fd = fd = socket(AF_NIT, SOCK_RAW|SOCK_CLOEXEC, NITPROTO_RAW);
|
|
|
|
if (fd < 0) {
|
|
|
|
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
|
|
|
"socket: %s", pcap_strerror(errno));
|
2013-09-20 15:13:12 +00:00
|
|
|
Index: libpcap-1.4.0/pcap-sita.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-sita.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-sita.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -329,7 +329,7 @@ static int open_with_IOP(unit_t *u, int
|
2012-08-27 19:38:03 +00:00
|
|
|
u->serv_addr->sin_addr.s_addr = inet_addr(ip);
|
|
|
|
u->serv_addr->sin_port = htons(IOP_SNIFFER_PORT);
|
|
|
|
|
|
|
|
- if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
|
|
|
+ if ((sockfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0)) < 0) {
|
|
|
|
fprintf(stderr, "pcap can't open a socket for connecting to IOP at %s\n", ip);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-20 15:13:12 +00:00
|
|
|
Index: libpcap-1.4.0/pcap-snit.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-snit.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-snit.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -297,9 +297,9 @@ pcap_activate_snit(pcap_t *p)
|
|
|
|
* the device in question) can be indicated at open
|
|
|
|
* time.
|
2012-08-27 19:38:03 +00:00
|
|
|
*/
|
2013-09-20 15:13:12 +00:00
|
|
|
- p->fd = fd = open(dev, O_RDWR);
|
|
|
|
+ p->fd = fd = open(dev, O_RDWR|O_CLOEXEC);
|
|
|
|
if (fd < 0 && errno == EACCES)
|
|
|
|
- p->fd = fd = open(dev, O_RDONLY);
|
|
|
|
+ p->fd = fd = open(dev, O_RDONLY|O_CLOEXEC);
|
2012-08-27 19:38:03 +00:00
|
|
|
if (fd < 0) {
|
2013-09-20 15:13:12 +00:00
|
|
|
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dev,
|
|
|
|
pcap_strerror(errno));
|
|
|
|
Index: libpcap-1.4.0/pcap-snoop.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-snoop.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-snoop.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -205,7 +205,7 @@ pcap_activate_snoop(pcap_t *p)
|
|
|
|
int snooplen;
|
|
|
|
struct ifreq ifr;
|
2012-08-27 19:38:03 +00:00
|
|
|
|
2013-09-20 15:13:12 +00:00
|
|
|
- fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
|
|
|
|
+ fd = socket(PF_RAW, SOCK_RAW|SOCK_CLOEXEC, RAWPROTO_SNOOP);
|
|
|
|
if (fd < 0) {
|
|
|
|
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snoop socket: %s",
|
|
|
|
pcap_strerror(errno));
|
|
|
|
Index: libpcap-1.4.0/pcap-usb-linux.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/pcap-usb-linux.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/pcap-usb-linux.c 2013-09-13 20:17:59.000000000 +0100
|
2012-08-27 19:38:03 +00:00
|
|
|
@@ -252,7 +252,7 @@ probe_devices(int bus)
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "/dev/bus/usb/%03d/%s", bus, data->d_name);
|
|
|
|
|
|
|
|
- fd = open(buf, O_RDWR);
|
|
|
|
+ fd = open(buf, O_RDWR|O_CLOEXEC);
|
|
|
|
if (fd == -1)
|
|
|
|
continue;
|
|
|
|
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -353,7 +353,7 @@ usb_activate(pcap_t* handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
|
|
|
|
/*now select the read method: try to open binary interface */
|
|
|
|
snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handle->md.ifindex);
|
|
|
|
- handle->fd = open(full_path, O_RDONLY, 0);
|
|
|
|
+ handle->fd = open(full_path, O_RDONLY|O_CLOEXEC, 0);
|
|
|
|
if (handle->fd >= 0)
|
|
|
|
{
|
|
|
|
if (handle->opt.rfmon) {
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -388,7 +388,7 @@ usb_activate(pcap_t* handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
else {
|
|
|
|
/*Binary interface not available, try open text interface */
|
|
|
|
snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR"/%dt", handle->md.ifindex);
|
|
|
|
- handle->fd = open(full_path, O_RDONLY, 0);
|
|
|
|
+ handle->fd = open(full_path, O_RDONLY|O_CLOEXEC, 0);
|
|
|
|
if (handle->fd < 0)
|
|
|
|
{
|
|
|
|
if (errno == ENOENT)
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -398,7 +398,7 @@ usb_activate(pcap_t* handle)
|
2012-08-27 19:38:03 +00:00
|
|
|
* the old location.
|
|
|
|
*/
|
|
|
|
snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handle->md.ifindex);
|
|
|
|
- handle->fd = open(full_path, O_RDONLY, 0);
|
|
|
|
+ handle->fd = open(full_path, O_RDONLY|O_CLOEXEC, 0);
|
|
|
|
}
|
|
|
|
if (handle->fd < 0) {
|
|
|
|
/* no more fallback, give it up*/
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -664,7 +664,7 @@ usb_stats_linux(pcap_t *handle, struct p
|
2012-08-27 19:38:03 +00:00
|
|
|
int fd;
|
|
|
|
|
|
|
|
snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
|
|
|
|
- fd = open(string, O_RDONLY, 0);
|
|
|
|
+ fd = open(string, O_RDONLY|O_CLOEXEC, 0);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
if (errno == ENOENT)
|
2013-09-20 15:13:12 +00:00
|
|
|
@@ -674,7 +674,7 @@ usb_stats_linux(pcap_t *handle, struct p
|
2012-08-27 19:38:03 +00:00
|
|
|
* location.
|
|
|
|
*/
|
|
|
|
snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handle->md.ifindex);
|
|
|
|
- fd = open(string, O_RDONLY, 0);
|
|
|
|
+ fd = open(string, O_RDONLY|O_CLOEXEC, 0);
|
|
|
|
}
|
|
|
|
if (fd < 0) {
|
|
|
|
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
2013-09-20 15:13:12 +00:00
|
|
|
Index: libpcap-1.4.0/savefile.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/savefile.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/savefile.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -189,7 +189,7 @@ pcap_open_offline(const char *fname, cha
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#if !defined(WIN32) && !defined(MSDOS)
|
|
|
|
- fp = fopen(fname, "r");
|
|
|
|
+ fp = fopen(fname, "re");
|
|
|
|
#else
|
|
|
|
fp = fopen(fname, "rb");
|
|
|
|
#endif
|
|
|
|
Index: libpcap-1.4.0/sf-pcap.c
|
|
|
|
===================================================================
|
|
|
|
--- libpcap-1.4.0.orig/sf-pcap.c 2013-02-21 03:51:49.000000000 +0000
|
|
|
|
+++ libpcap-1.4.0/sf-pcap.c 2013-09-13 20:17:59.000000000 +0100
|
|
|
|
@@ -550,7 +550,7 @@ pcap_dump_open(pcap_t *p, const char *fn
|
|
|
|
fname = "standard output";
|
|
|
|
} else {
|
|
|
|
#if !defined(WIN32) && !defined(MSDOS)
|
|
|
|
- f = fopen(fname, "w");
|
|
|
|
+ f = fopen(fname, "we");
|
|
|
|
#else
|
|
|
|
f = fopen(fname, "wb");
|
|
|
|
#endif
|