aboutsummaryrefslogtreecommitdiff
path: root/sand-leek.c
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-04-30 20:21:53 +1200
committerDavid Phillips <david@sighup.nz>2017-04-30 20:21:53 +1200
commita6bb6e11de058da38136dc2b5ba29a29d74a7985 (patch)
treea74ec2115a51484ecca592a3200770a16f027e4f /sand-leek.c
parentf6260117327d8edf34a955f1bbb3c1ce5bf4fcda (diff)
downloadsand-leek-a6bb6e11de058da38136dc2b5ba29a29d74a7985.tar.xz
Add sanity check to search string
Diffstat (limited to 'sand-leek.c')
-rw-r--r--sand-leek.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sand-leek.c b/sand-leek.c
index df34574..130d322 100644
--- a/sand-leek.c
+++ b/sand-leek.c
@@ -229,6 +229,7 @@ main(int argc, char **argv) {
int opt = '\0';
int thread_count = 1;
int i = 0;
+ size_t offset = 0;
pthread_t *workers = NULL;
unsigned long volatile *khash_count = NULL;
unsigned long khashes = 0;
@@ -254,6 +255,15 @@ main(int argc, char **argv) {
search_len = strlen(search);
+ if ((offset = strspn(search, base32_lookup)) != search_len) {
+ fprintf(stderr,
+ "Error: search contains non-base-32 character(s): %c\n"
+ "I cannot search for something that will never occur\n",
+ search[offset]
+ );
+ return 1;
+ }
+
workers = calloc(thread_count, sizeof(pthread_t));
if (!workers) {
perror("worker thread calloc");