]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add checks for strdup() failure.
authorBill Parker <[email protected]>
Mon, 13 Jul 2015 20:04:08 +0000 (13:04 -0700)
committerGuy Harris <[email protected]>
Mon, 13 Jul 2015 20:04:08 +0000 (13:04 -0700)
tcpdump.c

index 29a70cee93992aa08ba86a82a73881cca02d9159..bacbc7dd9a281a33d5f44d9fa9b0d2b839604ef7 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1133,10 +1133,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 '#':
@@ -1604,6 +1608,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) {