Call usage when no arguments are supplied
authorSofian Brabez <sbz@FreeBSD.org>
Sat, 12 Nov 2016 05:27:41 +0000 (06:27 +0100)
committerSofian Brabez <sbz@FreeBSD.org>
Mon, 16 Oct 2017 16:09:51 +0000 (18:09 +0200)
ctfdump.c

index 7a47a0d1cb04adafd8afc628b0ba99c7c372bd65..a22b101f46ac9948dc51a6ea0d265c354db3d83d 100644 (file)
--- a/ctfdump.c
+++ b/ctfdump.c
@@ -78,6 +78,9 @@ main(int argc, char *argv[])
 
        setlocale(LC_ALL, "");
 
+       if (argc == 1)
+               usage();
+
        while ((ch = getopt(argc, argv, "dfhlst")) != -1) {
                switch (ch) {
                case 'd':
@@ -106,6 +109,9 @@ main(int argc, char *argv[])
        argc -= optind;
        argv += optind;
 
+       if (*argv == NULL)
+               usage();
+
        /* Dump everything by default */
        if (flags == 0)
                flags = 0xff;