aboutsummaryrefslogtreecommitdiff
path: root/sand-leek.c
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-04-27 18:56:46 +1200
committerDavid Phillips <david@sighup.nz>2017-04-27 18:56:46 +1200
commit6f511706f3fc6dc1ab301cb63ad1853f489ab3d3 (patch)
treefed97ecf202bd9bb814a5be3a9b56430118dde72 /sand-leek.c
parenta6245af58eccd4ba7097bff72325cb05f5f02c61 (diff)
downloadsand-leek-6f511706f3fc6dc1ab301cb63ad1853f489ab3d3.tar.xz
Correct command line argument checking
Diffstat (limited to 'sand-leek.c')
-rw-r--r--sand-leek.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sand-leek.c b/sand-leek.c
index 4327f4d..5074adb 100644
--- a/sand-leek.c
+++ b/sand-leek.c
@@ -137,6 +137,16 @@ STOP:
return NULL;
}
+void
+die_usage(const char *argv0) {
+ fprintf(stderr,
+ "usage: %s [-t threads] -s search\n"
+ "searches for keys for onion addresses beginning with `search`\n",
+ argv0
+ );
+ exit(1);
+}
+
int
main(int argc, char **argv) {
char opt = '\0';
@@ -158,7 +168,11 @@ main(int argc, char **argv) {
}
if (thread_count <= 0) {
- fprintf(stderr, "thread count must be > 0\n");
+ die_usage(argv[0]);
+ }
+
+ if (search == NULL || strlen(search) <= 0) {
+ die_usage(argv[0]);
}
search_len = strlen(search);