]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
dBm values get printed as dB
[tcpdump] / tcpdump.c
index 13becf7ee69a9b31a5614c65b47da91f02a31011..207908a583d91eb237665a6dc34f67aa4b329686 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -164,7 +164,8 @@ static RETSIGTYPE cleanup(int);
 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 *);
@@ -217,7 +218,7 @@ struct dump_info {
 
 #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;
@@ -250,7 +251,7 @@ show_tstamp_types_and_exit(const char *device, pcap_t *pd)
 #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;
@@ -492,12 +493,13 @@ droproot(const char *username, const char *chroot_dir)
                        }
                }
 #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 ||
@@ -1132,10 +1134,14 @@ main(int argc, char **argv)
 #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 '#':
@@ -1321,7 +1327,7 @@ main(int argc, char **argv)
                        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);
@@ -1442,7 +1448,7 @@ main(int argc, char **argv)
                        }
 #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)
@@ -1603,6 +1609,10 @@ main(int argc, char **argv)
                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) {
@@ -1653,7 +1663,7 @@ main(int argc, char **argv)
        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