#ifdef WIN32
#include "w32_fzs.h"
-extern int strcasecmp (const char *__s1, const char *__s2);
extern int SIZE_BUF;
#define off_t long
#define uint UINT
#include "setsignal.h"
#include "gmt2local.h"
#include "pcap-missing.h"
+#include "ascii_strcasecmp.h"
#include "print.h"
static RETSIGTYPE child_cleanup(int);
static void print_version(void);
static void print_usage(void);
-static void show_dlts_and_exit(const char *device, pcap_t *pd) __attribute__((noreturn));
+static void show_tstamp_types_and_exit(const char *device) __attribute__((noreturn));
+static void show_dlts_and_exit(const char *device) __attribute__((noreturn));
static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
static void
-show_tstamp_types_and_exit(const char *device, pcap_t *pd)
+show_tstamp_types_and_exit(const char *device)
{
int n_tstamp_types;
int *tstamp_types = 0;
#endif
static void
-show_dlts_and_exit(const char *device, pcap_t *pd)
+show_dlts_and_exit(const char *device)
{
int n_dlts, i;
int *dlts = 0;
}
}
#ifdef HAVE_LIBCAP_NG
- int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
- if (ret < 0) {
- fprintf(stderr, "error : ret %d\n", ret);
- }
- else {
- fprintf(stderr, "dropped privs to %s\n", username);
+ {
+ int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
+ if (ret < 0) {
+ fprintf(stderr, "error : ret %d\n", ret);
+ } else {
+ fprintf(stderr, "dropped privs to %s\n", username);
+ }
}
#else
if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
#ifdef HAVE_PCAP_SETDIRECTION
case 'Q':
- if (strcasecmp(optarg, "in") == 0)
+ if (ascii_strcasecmp(optarg, "in") == 0)
Qflag = PCAP_D_IN;
- else if (strcasecmp(optarg, "out") == 0)
+ else if (ascii_strcasecmp(optarg, "out") == 0)
Qflag = PCAP_D_OUT;
- else if (strcasecmp(optarg, "inout") == 0)
+ else if (ascii_strcasecmp(optarg, "inout") == 0)
Qflag = PCAP_D_INOUT;
else
error("unknown capture direction `%s'", optarg);
break;
case 'T':
- if (strcasecmp(optarg, "vat") == 0)
+ if (ascii_strcasecmp(optarg, "vat") == 0)
ndo->ndo_packettype = PT_VAT;
- else if (strcasecmp(optarg, "wb") == 0)
+ else if (ascii_strcasecmp(optarg, "wb") == 0)
ndo->ndo_packettype = PT_WB;
- else if (strcasecmp(optarg, "rpc") == 0)
+ else if (ascii_strcasecmp(optarg, "rpc") == 0)
ndo->ndo_packettype = PT_RPC;
- else if (strcasecmp(optarg, "rtp") == 0)
+ else if (ascii_strcasecmp(optarg, "rtp") == 0)
ndo->ndo_packettype = PT_RTP;
- else if (strcasecmp(optarg, "rtcp") == 0)
+ else if (ascii_strcasecmp(optarg, "rtcp") == 0)
ndo->ndo_packettype = PT_RTCP;
- else if (strcasecmp(optarg, "snmp") == 0)
+ else if (ascii_strcasecmp(optarg, "snmp") == 0)
ndo->ndo_packettype = PT_SNMP;
- else if (strcasecmp(optarg, "cnfp") == 0)
+ else if (ascii_strcasecmp(optarg, "cnfp") == 0)
ndo->ndo_packettype = PT_CNFP;
- else if (strcasecmp(optarg, "tftp") == 0)
+ else if (ascii_strcasecmp(optarg, "tftp") == 0)
ndo->ndo_packettype = PT_TFTP;
- else if (strcasecmp(optarg, "aodv") == 0)
+ else if (ascii_strcasecmp(optarg, "aodv") == 0)
ndo->ndo_packettype = PT_AODV;
- else if (strcasecmp(optarg, "carp") == 0)
+ else if (ascii_strcasecmp(optarg, "carp") == 0)
ndo->ndo_packettype = PT_CARP;
- else if (strcasecmp(optarg, "radius") == 0)
+ else if (ascii_strcasecmp(optarg, "radius") == 0)
ndo->ndo_packettype = PT_RADIUS;
- else if (strcasecmp(optarg, "zmtp1") == 0)
+ else if (ascii_strcasecmp(optarg, "zmtp1") == 0)
ndo->ndo_packettype = PT_ZMTP1;
- else if (strcasecmp(optarg, "vxlan") == 0)
+ else if (ascii_strcasecmp(optarg, "vxlan") == 0)
ndo->ndo_packettype = PT_VXLAN;
- else if (strcasecmp(optarg, "pgm") == 0)
+ else if (ascii_strcasecmp(optarg, "pgm") == 0)
ndo->ndo_packettype = PT_PGM;
- else if (strcasecmp(optarg, "pgm_zmtp1") == 0)
+ else if (ascii_strcasecmp(optarg, "pgm_zmtp1") == 0)
ndo->ndo_packettype = PT_PGM_ZMTP1;
- else if (strcasecmp(optarg, "lmp") == 0)
+ else if (ascii_strcasecmp(optarg, "lmp") == 0)
ndo->ndo_packettype = PT_LMP;
else
error("unknown packet type `%s'", optarg);
#endif
case 'z':
zflag = strdup(optarg);
+ if (zflag == NULL)
+ error("Unable to allocate memory for -z argument");
break;
case 'Z':
username = strdup(optarg);
+ if (username == NULL)
+ error("Unable to allocate memory for -Z argument");
break;
case '#':
error("%s", ebuf);
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
if (Jflag)
- show_tstamp_types_and_exit(device, pd);
+ show_tstamp_types_and_exit(device);
#endif
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
status = pcap_set_tstamp_precision(pd, ndo->ndo_tstamp_precision);
}
#endif /* !defined(HAVE_PCAP_CREATE) && defined(WIN32) */
if (Lflag)
- show_dlts_and_exit(device, pd);
+ show_dlts_and_exit(device);
if (ndo->ndo_dlt >= 0) {
#ifdef HAVE_PCAP_SET_DATALINK
if (pcap_set_datalink(pd, ndo->ndo_dlt) < 0)
if (Cflag != 0 || Gflag != 0) {
#ifdef HAVE_CAPSICUM
dumpinfo.WFileName = strdup(basename(WFileName));
+ if (dumpinfo.WFileName == NULL) {
+ error("Unable to allocate memory for file %s",
+ WFileName);
+ }
dumpinfo.dirfd = open(dirname(WFileName),
O_DIRECTORY | O_RDONLY);
if (dumpinfo.dirfd < 0) {
if (ndo->ndo_vflag > 0 && WFileName) {
/*
* When capturing to a file, "-v" means tcpdump should,
- * every 10 secodns, "v"erbosely report the number of
+ * every 10 seconds, "v"erbosely report the number of
* packets captured.
*/
#ifdef USE_WIN32_MM_TIMER