summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-02-26 12:33:23 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2019-02-26 12:33:23 +0200
commit7fbfdf2af731f500e3df3ca8207e6822f87f1bc9 (patch)
tree7dd1beac6cc0854d7b4930ec111ec0cb261cb588 /src/test
parent626e6d2c394673ca46a44616a76b33699d0cf763 (diff)
parentf632335feb27b45a3ee5eb64690826bda52467bd (diff)
downloadtor-7fbfdf2af731f500e3df3ca8207e6822f87f1bc9.tar.gz
tor-7fbfdf2af731f500e3df3ca8207e6822f87f1bc9.zip
Merge branch 'tor-github/pr/611'
Diffstat (limited to 'src/test')
-rw-r--r--src/test/fuzz/fuzz_strops.c8
-rw-r--r--src/test/test_crypto.c8
-rw-r--r--src/test/test_util_format.c4
3 files changed, 7 insertions, 13 deletions
diff --git a/src/test/fuzz/fuzz_strops.c b/src/test/fuzz/fuzz_strops.c
index 64a6453050..a37cbb5be8 100644
--- a/src/test/fuzz/fuzz_strops.c
+++ b/src/test/fuzz/fuzz_strops.c
@@ -86,15 +86,13 @@ b16_enc(const chunk_t *inp)
return ch;
}
-#if 0
static chunk_t *
b32_dec(const chunk_t *inp)
{
chunk_t *ch = chunk_new(inp->len);//XXXX
int r = base32_decode((char *)ch->buf, ch->len, (char *)inp->buf, inp->len);
if (r >= 0) {
- ch->len = r; // XXXX we need some way to get the actual length of
- // XXXX the output here.
+ ch->len = r;
} else {
chunk_free(ch);
}
@@ -108,7 +106,6 @@ b32_enc(const chunk_t *inp)
ch->len = strlen((char *) ch->buf);
return ch;
}
-#endif
static chunk_t *
b64_dec(const chunk_t *inp)
@@ -222,10 +219,7 @@ fuzz_main(const uint8_t *stdin_buf, size_t data_size)
ENCODE_ROUNDTRIP(b16_enc, b16_dec, chunk_free_);
break;
case 1:
- /*
- XXXX see notes above about our base-32 functions.
ENCODE_ROUNDTRIP(b32_enc, b32_dec, chunk_free_);
- */
break;
case 2:
ENCODE_ROUNDTRIP(b64_enc, b64_dec, chunk_free_);
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 0b57448bcf..0903c5c49a 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -1703,13 +1703,13 @@ test_crypto_base32_decode(void *arg)
/* Encode and decode a random string. */
base32_encode(encoded, 96 + 1, plain, 60);
res = base32_decode(decoded, 60, encoded, 96);
- tt_int_op(res,OP_EQ, 0);
+ tt_int_op(res, OP_EQ, 60);
tt_mem_op(plain,OP_EQ, decoded, 60);
/* Encode, uppercase, and decode a random string. */
base32_encode(encoded, 96 + 1, plain, 60);
tor_strupper(encoded);
res = base32_decode(decoded, 60, encoded, 96);
- tt_int_op(res,OP_EQ, 0);
+ tt_int_op(res, OP_EQ, 60);
tt_mem_op(plain,OP_EQ, decoded, 60);
/* Change encoded string and decode. */
if (encoded[0] == 'A' || encoded[0] == 'a')
@@ -1717,12 +1717,12 @@ test_crypto_base32_decode(void *arg)
else
encoded[0] = 'A';
res = base32_decode(decoded, 60, encoded, 96);
- tt_int_op(res,OP_EQ, 0);
+ tt_int_op(res, OP_EQ, 60);
tt_mem_op(plain,OP_NE, decoded, 60);
/* Bad encodings. */
encoded[0] = '!';
res = base32_decode(decoded, 60, encoded, 96);
- tt_int_op(0, OP_GT, res);
+ tt_int_op(res, OP_LT, 0);
done:
;
diff --git a/src/test/test_util_format.c b/src/test/test_util_format.c
index 3a0b41faa5..c8945a707c 100644
--- a/src/test/test_util_format.c
+++ b/src/test/test_util_format.c
@@ -346,7 +346,7 @@ test_util_format_base32_decode(void *arg)
const char *src = "mjwgc2dcnrswqmjs";
ret = base32_decode(dst, strlen(expected), src, strlen(src));
- tt_int_op(ret, OP_EQ, 0);
+ tt_int_op(ret, OP_EQ, 10);
tt_str_op(expected, OP_EQ, dst);
}
@@ -357,7 +357,7 @@ test_util_format_base32_decode(void *arg)
const char *src = "mjwgc2dcnrswq";
ret = base32_decode(dst, strlen(expected), src, strlen(src));
- tt_int_op(ret, OP_EQ, 0);
+ tt_int_op(ret, OP_EQ, 8);
tt_mem_op(expected, OP_EQ, dst, strlen(expected));
}