summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-05-03 17:00:45 +0000
committerjsing <>2014-05-03 17:00:45 +0000
commit77a8ee84e97122ed58ad5a8b08ad73fe5c38d929 (patch)
tree476c1d8c6f19e98cffe43a1508bfa990d5e5e5f9
parent514338c77dd677946d110257af15041ce31eb6d0 (diff)
downloadopenbsd-77a8ee84e97122ed58ad5a8b08ad73fe5c38d929.tar.gz
openbsd-77a8ee84e97122ed58ad5a8b08ad73fe5c38d929.tar.bz2
openbsd-77a8ee84e97122ed58ad5a8b08ad73fe5c38d929.zip
Update the base64 regress test and enable a test that would previously
have resulted in a segfault. Also update the resulting output bytes now that the invalid/corrupt input is detected and rejected; unless you're using BIO_FLAGS_BASE64_NO_NL, in which case you still get a stream of zero value bytes and no way of knowing that the data is invalid/corrupt.
-rw-r--r--src/regress/lib/libcrypto/base64/base64test.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/regress/lib/libcrypto/base64/base64test.c b/src/regress/lib/libcrypto/base64/base64test.c
index 2db10f6007..a7d167e97d 100644
--- a/src/regress/lib/libcrypto/base64/base64test.c
+++ b/src/regress/lib/libcrypto/base64/base64test.c
@@ -67,17 +67,6 @@ struct base64_test base64_tests[] = {
67 48, 67 48,
68 34, 68 34,
69 }, 69 },
70
71#ifdef crash
72 {
73 "",
74 -1,
75 "YWJjZA======================================================"
76 "============",
77 74,
78 0,
79 },
80#endif
81}; 70};
82 71
83#define N_TESTS (sizeof(base64_tests) / sizeof(*base64_tests)) 72#define N_TESTS (sizeof(base64_tests) / sizeof(*base64_tests))
@@ -86,14 +75,14 @@ struct base64_test base64_nl_tests[] = {
86 75
87 /* Corrupt/invalid encodings. */ 76 /* Corrupt/invalid encodings. */
88 { "", -1, "", 0, 0, }, 77 { "", -1, "", 0, 0, },
89 { "", -1, "!!!!", 4, 0, }, /* 20 */ 78 { "", -1, "!!!!", 4, 0, },
90 { "", -1, "====", 4, 1, }, /* XXX - output ix 0x0. */ 79 { "", -1, "====", 4, 0, },
91 { "", -1, "x===", 4, 1, }, 80 { "", -1, "x===", 4, 0, },
92 { "", -1, "=AAA", 4, 3, }, 81 { "", -1, "=AAA", 4, 0, },
93 { "", -1, "A=AA", 4, 3, }, 82 { "", -1, "A=AA", 4, 0, },
94 { "", -1, "AA=A", 4, 2, }, 83 { "", -1, "AA=A", 4, 0, },
95 { "", -1, "AA==A", 5, 0, }, 84 { "", -1, "AA==A", 5, 0, },
96 { "", -1, "AAA=AAAA", 8, 6, }, 85 { "", -1, "AAA=AAAA", 8, 0, },
97 { "", -1, "AAAAA", 5, 0, }, 86 { "", -1, "AAAAA", 5, 0, },
98 { "", -1, "AAAAAA", 6, 0, }, 87 { "", -1, "AAAAAA", 6, 0, },
99 { "", -1, "A=", 2, 0, }, 88 { "", -1, "A=", 2, 0, },
@@ -119,6 +108,14 @@ struct base64_test base64_nl_tests[] = {
119 { "sure", 4, "c3VyZQ=\n=", 9, 4, }, 108 { "sure", 4, "c3VyZQ=\n=", 9, 4, },
120 { "sure", 4, "c3VyZQ=\r\n\r\n=", 12, 4, }, 109 { "sure", 4, "c3VyZQ=\r\n\r\n=", 12, 4, },
121 110
111 {
112 "",
113 -1,
114 "YWJjZA======================================================"
115 "============",
116 74,
117 0,
118 },
122}; 119};
123 120
124#define N_NL_TESTS (sizeof(base64_nl_tests) / sizeof(*base64_nl_tests)) 121#define N_NL_TESTS (sizeof(base64_nl_tests) / sizeof(*base64_nl_tests))
@@ -133,7 +130,7 @@ struct base64_test base64_no_nl_tests[] = {
133 130
134 /* Corrupt/invalid encodings. */ 131 /* Corrupt/invalid encodings. */
135 { "", -1, "", 0, 0, }, 132 { "", -1, "", 0, 0, },
136 { "", -1, "!!!!", 4, 0, }, /* 20 */ 133 { "", -1, "!!!!", 4, 0, },
137 { "", -1, "====", 4, 1, }, 134 { "", -1, "====", 4, 1, },
138 { "", -1, "x===", 4, 1, }, 135 { "", -1, "x===", 4, 1, },
139 { "", -1, "=AAA", 4, 3, }, 136 { "", -1, "=AAA", 4, 3, },
@@ -165,6 +162,18 @@ struct base64_test base64_no_nl_tests[] = {
165 { "sure", -1, "c3VyZQ=\n=", 9, 0, }, 162 { "sure", -1, "c3VyZQ=\n=", 9, 0, },
166 { "sure", -1, "c3VyZQ=\r\n\r\n=", 12, 0, }, 163 { "sure", -1, "c3VyZQ=\r\n\r\n=", 12, 0, },
167 164
165 /*
166 * This is invalid, yet results in 'abcd' followed by a stream of
167 * zero value bytes.
168 */
169 {
170 "",
171 -1,
172 "YWJjZA======================================================"
173 "============",
174 74,
175 52,
176 },
168}; 177};
169 178
170#define N_NO_NL_TESTS (sizeof(base64_no_nl_tests) / sizeof(*base64_no_nl_tests)) 179#define N_NO_NL_TESTS (sizeof(base64_no_nl_tests) / sizeof(*base64_no_nl_tests))