diff --git a/0005-Fix-scaling-of-time-stamps.patch b/0005-Fix-scaling-of-time-stamps.patch new file mode 100644 index 0000000..951865f --- /dev/null +++ b/0005-Fix-scaling-of-time-stamps.patch @@ -0,0 +1,71 @@ +From 6a9c2cb19cb7eebdab8d2fa7a592d39130f8bf61 Mon Sep 17 00:00:00 2001 +From: Guy Harris +Date: Mon, 1 Dec 2014 13:53:01 -0800 +Subject: [PATCH] Fix scaling of time stamps. + +Addresses GitHub issue #396. +--- + sf-pcap-ng.c | 29 +++++++++++++++++++++-------- + 1 file changed, 21 insertions(+), 8 deletions(-) + +diff --git a/sf-pcap-ng.c b/sf-pcap-ng.c +index fae4086..ea62157 100644 +--- a/sf-pcap-ng.c ++++ b/sf-pcap-ng.c +@@ -1210,10 +1210,16 @@ found: + } + + /* +- * Convert the time stamp to a struct timeval. ++ * Convert the time stamp to seconds and fractions of a second, ++ * with the fractions being in units of the file-supplied resolution. + */ + sec = t / ps->ifaces[interface_id].tsresol + ps->ifaces[interface_id].tsoffset; + frac = t % ps->ifaces[interface_id].tsresol; ++ ++ /* ++ * Convert the fractions from units of the file-supplied resolution ++ * to units of the user-requested resolution. ++ */ + switch (ps->ifaces[interface_id].scale_type) { + + case PASS_THROUGH: +@@ -1227,21 +1233,28 @@ found: + case SCALE_DOWN: + /* + * The interface resolution is different from what the +- * user wants; scale up or down to that resolution. ++ * user wants; convert the fractions to units of the ++ * resolution the user requested by multiplying by the ++ * quotient of the user-requested resolution and the ++ * file-supplied resolution. We do that by multiplying ++ * by the user-requested resolution and dividing by the ++ * file-supplied resolution, as the quotient might not ++ * fit in an integer. + * + * XXX - if ps->ifaces[interface_id].tsresol is a power + * of 10, we could just multiply by the quotient of +- * ps->ifaces[interface_id].tsresol and ps->user_tsresol +- * in the scale-up case, and divide by the quotient of + * ps->user_tsresol and ps->ifaces[interface_id].tsresol +- * in the scale-down case, as we know those are integers, +- * which would involve fewer arithmetic operations. ++ * in the scale-up case, and divide by the quotient of ++ * ps->ifaces[interface_id].tsresol and ps->user_tsresol ++ * in the scale-down case, as we know those will be integers. ++ * That would involve fewer arithmetic operations, and ++ * would run less risk of overflow. + * + * Is there something clever we could do if + * ps->ifaces[interface_id].tsresol is a power of 2? + */ +- frac *= ps->ifaces[interface_id].tsresol; +- frac /= ps->user_tsresol; ++ frac *= ps->user_tsresol; ++ frac /= ps->ifaces[interface_id].tsresol; + break; + } + hdr->ts.tv_sec = sec; +-- +1.8.3.1 + diff --git a/libpcap.spec b/libpcap.spec index ceea2b9..a53b18e 100644 --- a/libpcap.spec +++ b/libpcap.spec @@ -1,7 +1,7 @@ Name: libpcap Epoch: 14 Version: 1.6.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A system-independent interface for user-level packet capture Group: Development/Libraries License: BSD with advertising @@ -14,6 +14,7 @@ Patch0001: 0001-man-tcpdump-and-tcpslice-have-manpages-in-man8.patch Patch0002: 0002-pcap-config-mitigate-multilib-conflict.patch Patch0003: 0003-pcap-linux-apparently-ctc-interfaces-on-s390-has-eth.patch Patch0004: 0004-pcap-linux-don-t-use-TPACKETV3-for-memory-mmapped-ca.patch +Patch0005: 0005-Fix-scaling-of-time-stamps.patch %description Libpcap provides a portable framework for low-level network @@ -83,6 +84,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libpcap.a %{_mandir}/man5/pcap*.5* %changelog +* Mon Feb 23 2015 Michal Sekletar - 14:1.6.2-2 +- fix scaling of pcap-ng timestamps (#1169322) + * Mon Sep 29 2014 Michal Sekletar - 14:1.6.2-1 - update to 1.6.2 (#1124174) - disable TPACKET_V3 support (#1131500)