diff options
author | David Phillips <david@sighup.nz> | 2017-05-23 14:36:12 +1200 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-05-23 14:36:12 +1200 |
commit | 4995b5fe9a01a10b2487bd73bb214a4584bc4c1c (patch) | |
tree | f7909e6a7be84a940f2952da97ea9c53971a896c | |
parent | 91576b381d9f4d714dc9a7f559ca9d13898e01e3 (diff) | |
download | sand-leek-4995b5fe9a01a10b2487bd73bb214a4584bc4c1c.tar.xz |
Fix bug in check_base32 when first character was invalid
-rw-r--r-- | onion_base32.c | 2 | ||||
-rw-r--r-- | sand-leek.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/onion_base32.c b/onion_base32.c index eff5097..041ac3e 100644 --- a/onion_base32.c +++ b/onion_base32.c @@ -10,7 +10,7 @@ check_base32(char *subject) { if ((offset = strspn(subject, base32_lookup)) != strlen(subject)) { return offset; } - return 0; + return -1; } /* Simple and reliable base32 algorithm - "old trusty" diff --git a/sand-leek.c b/sand-leek.c index 899726a..8554960 100644 --- a/sand-leek.c +++ b/sand-leek.c @@ -284,7 +284,7 @@ main(int argc, char **argv) { int opt = '\0'; int thread_count = 1; int i = 0; - size_t offset = 0; + ssize_t offset = 0; pthread_t *workers = NULL; unsigned long volatile *khashes = NULL; @@ -312,7 +312,7 @@ main(int argc, char **argv) { search_len = strlen(search); - if ((offset = check_base32(search))) { + if ((offset = check_base32(search)) >= 0) { fprintf(stderr, "Error: search contains non-base-32 character(s): %c\n" "I cannot search for something that will never occur\n", |