[packages] tcpdump: properly handle iface names with leading digits (#7572)

git-svn-id: svn://svn.openwrt.org/openwrt/packages@22081 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2010-07-07 01:09:45 +00:00
parent 6f0ae71eba
commit dd917db23b
3 changed files with 35 additions and 7 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=tcpdump
PKG_VERSION:=4.0.0
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.tcpdump.org/release/ \

View File

@ -0,0 +1,28 @@
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -66,6 +66,7 @@ extern int SIZE_BUF;
#include <stdlib.h>
#include <string.h>
#include <limits.h>
+#include <ctype.h>
#ifndef WIN32
#include <sys/wait.h>
#include <sys/resource.h>
@@ -501,6 +502,7 @@ main(int argc, char **argv)
#ifdef HAVE_PCAP_FINDALLDEVS
pcap_if_t *devpointer;
int devnum;
+ char *devp;
#endif
int status;
#ifdef WIN32
@@ -639,7 +641,8 @@ main(int argc, char **argv)
* It can be useful on Windows, where more than
* one interface can have the same name.
*/
- if ((devnum = atoi(optarg)) != 0) {
+ for (devp = optarg; *devp && isdigit(*devp); devp++);
+ if ((!*devp || isspace(*devp)) && (devnum = atoi(optarg)) != 0) {
if (devnum < 0)
error("Invalid adapter index");

View File

@ -206,7 +206,7 @@
if (!eflag)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -138,11 +138,14 @@ struct printer {
@@ -139,11 +139,14 @@ struct printer {
};
static struct printer printers[] = {
@ -221,7 +221,7 @@
{ token_if_print, DLT_IEEE802 },
#ifdef DLT_LANE8023
{ lane_if_print, DLT_LANE8023 },
@@ -157,19 +160,23 @@ static struct printer printers[] = {
@@ -158,19 +161,23 @@ static struct printer printers[] = {
#ifdef DLT_SLIP_BSDOS
{ sl_bsdos_if_print, DLT_SLIP_BSDOS },
#endif
@ -245,7 +245,7 @@
{ atm_if_print, DLT_ATM_RFC1483 },
#ifdef DLT_C_HDLC
{ chdlc_if_print, DLT_C_HDLC },
@@ -180,15 +187,19 @@ static struct printer printers[] = {
@@ -181,15 +188,19 @@ static struct printer printers[] = {
#ifdef DLT_PPP_SERIAL
{ ppp_hdlc_if_print, DLT_PPP_SERIAL },
#endif
@ -265,7 +265,7 @@
#ifdef DLT_LTALK
{ ltalk_if_print, DLT_LTALK },
#endif
@@ -207,12 +218,14 @@ static struct printer printers[] = {
@@ -208,12 +219,14 @@ static struct printer printers[] = {
#ifdef DLT_IP_OVER_FC
{ ipfc_if_print, DLT_IP_OVER_FC },
#endif
@ -280,7 +280,7 @@
#ifdef DLT_ENC
{ enc_if_print, DLT_ENC },
#endif
@@ -222,9 +235,11 @@ static struct printer printers[] = {
@@ -223,9 +236,11 @@ static struct printer printers[] = {
#ifdef DLT_APPLE_IP_OVER_IEEE1394
{ ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
#endif
@ -292,7 +292,7 @@
#ifdef DLT_JUNIPER_ATM1
{ juniper_atm1_print, DLT_JUNIPER_ATM1 },
#endif
@@ -276,6 +291,7 @@ static struct printer printers[] = {
@@ -277,6 +292,7 @@ static struct printer printers[] = {
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
{ bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
#endif