summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-12-09 07:46:54 +0000
committertb <>2022-12-09 07:46:54 +0000
commit7d30ffa93de4af659f4d19a6c9e1561e462428fc (patch)
tree4bebb72b01a6a05b99ec73a7151c609c5c11add3
parent913b3be406969b850b0ff8eb156d17ebe74b5d94 (diff)
downloadopenbsd-7d30ffa93de4af659f4d19a6c9e1561e462428fc.tar.gz
openbsd-7d30ffa93de4af659f4d19a6c9e1561e462428fc.tar.bz2
openbsd-7d30ffa93de4af659f4d19a6c9e1561e462428fc.zip
bio chain test: various minor readability tweaks
Align initialization in walk_backward() with walk_forward(), fix grammar in a comment and move initialization of oldhead_len in a place consistent with the other length initializations in that function
-rw-r--r--src/regress/lib/libcrypto/bio/bio_chain.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/regress/lib/libcrypto/bio/bio_chain.c b/src/regress/lib/libcrypto/bio/bio_chain.c
index 2fb6e7f872..81b3b862f7 100644
--- a/src/regress/lib/libcrypto/bio/bio_chain.c
+++ b/src/regress/lib/libcrypto/bio/bio_chain.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_chain.c,v 1.7 2022/12/08 18:34:00 tb Exp $ */ 1/* $OpenBSD: bio_chain.c,v 1.8 2022/12/09 07:46:54 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -243,8 +243,9 @@ walk_backward(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j,
243 if (start == NULL || end == NULL) 243 if (start == NULL || end == NULL)
244 goto done; 244 goto done;
245 245
246 len = 0;
247 prev = end; 246 prev = end;
247 len = 0;
248
248 do { 249 do {
249 next = prev; 250 next = prev;
250 prev = BIO_prev(prev); 251 prev = BIO_prev(prev);
@@ -277,6 +278,7 @@ check_chain(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j,
277{ 278{
278 if (!walk_forward(start, end, expected_len, i, j, fn, description)) 279 if (!walk_forward(start, end, expected_len, i, j, fn, description))
279 return 0; 280 return 0;
281
280 if (!walk_backward(start, end, expected_len, i, j, fn, description)) 282 if (!walk_backward(start, end, expected_len, i, j, fn, description))
281 return 0; 283 return 0;
282 284
@@ -318,9 +320,9 @@ check_chain(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j,
318 * After creating a new link, the new chain has length i + 1 + nitems(B) - j, 320 * After creating a new link, the new chain has length i + 1 + nitems(B) - j,
319 * oldtail has length nitems(A) - i - 1 and oldhead has length j. 321 * oldtail has length nitems(A) - i - 1 and oldhead has length j.
320 * 322 *
321 * Prior to bio_lib.c r1.40, BIO_set_next(A[i], B[j]) results in both A[i] and 323 * Prior to bio_lib.c r1.40, BIO_set_next(A[i], B[j]) would result in both A[i]
322 * B[j - 1] pointing at B[j] while B[j] points back at A[i]. The result is 324 * and B[j - 1] pointing at B[j] while B[j] would point back at A[i]. Calling
323 * again double frees. 325 * BIO_free_all(A[0]) and BIO_free_all(B[0]) results in a double free of B[j].
324 * 326 *
325 * XXX: Should check that the callback is called on BIO_push() as expected. 327 * XXX: Should check that the callback is called on BIO_push() as expected.
326 */ 328 */
@@ -354,9 +356,9 @@ link_chains_at(size_t i, size_t j, int use_bio_push)
354 new_start = A[0]; 356 new_start = A[0];
355 new_end = B[nitems(B) - 1]; 357 new_end = B[nitems(B) - 1];
356 358
357 oldhead_len = j;
358 oldhead_start = B[0]; 359 oldhead_start = B[0];
359 oldhead_end = BIO_prev(B[j]); 360 oldhead_end = BIO_prev(B[j]);
361 oldhead_len = j;
360 362
361 /* If we push B[0] or set next to B[0], the oldhead chain is empty. */ 363 /* If we push B[0] or set next to B[0], the oldhead chain is empty. */
362 if (j == 0) { 364 if (j == 0) {