about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-01-31 14:31:32 +0100
committerLeah Neukirchen <leah@vuxu.org>2018-01-31 14:32:00 +0100
commit2e775ff6f3a15c575b4ba4cf72e6db31cc7a227d (patch)
tree67e95bf044eef1675a1a3848d21d18b032dda729
parent871185b1ba7e1cfb41be9290e9c166190b7b1a5d (diff)
downloadnq-2e775ff6f3a15c575b4ba4cf72e6db31cc7a227d.tar.gz
nq-2e775ff6f3a15c575b4ba4cf72e6db31cc7a227d.tar.xz
nq-2e775ff6f3a15c575b4ba4cf72e6db31cc7a227d.zip
nq: properly check for empty command lines
`nq -q` could trigger a segfault before.
Found by Leonardo Taccari.

Fixes #25.
-rw-r--r--nq.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/nq.c b/nq.c
index d83fa02..78431fb 100644
--- a/nq.c
+++ b/nq.c
@@ -132,7 +132,7 @@ main(int argc, char *argv[])
 		}
 	}
 
-	if (argc <= 1) {
+	if (argc <= optind) {
 usage:
 		swrite(2, "usage: nq [-c] [-q] [-w ... | -t ... | CMD...]\n");
 		exit(1);