diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2022-08-07 07:08:28 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2022-09-16 10:07:15 +0200 |
commit | 30eba7f35983a917f1007bce45040c0af3442e42 (patch) | |
tree | abb5c026dad37c2072922d625cf38cca5423a5f3 /test | |
parent | 38ebfc3f5f83cbbd01011636d159ad3ed23e9765 (diff) | |
download | openssl-new-30eba7f35983a917f1007bce45040c0af3442e42.tar.gz |
stack.c: add missing direct error reporting and improve coding style
Doing so, had to fix sloppiness in using the stack API in crypto/conf/conf_def.c,
ssl/ssl_ciph.c, ssl/statem/statem_srvr.c, and mostly in test/helpers/ssltestlib.c.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18918)
Diffstat (limited to 'test')
-rw-r--r-- | test/helpers/ssltestlib.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c index 94ea1c53d8..9dca5e8363 100644 --- a/test/helpers/ssltestlib.c +++ b/test/helpers/ssltestlib.c @@ -350,8 +350,9 @@ static int mempacket_test_read(BIO *bio, char *out, int outl) unsigned int seq, offset, len, epoch; BIO_clear_retry_flags(bio); - thispkt = sk_MEMPACKET_value(ctx->pkts, 0); - if (thispkt == NULL || thispkt->num != ctx->currpkt) { + if (sk_MEMPACKET_num(ctx->pkts) <= 0 + || (thispkt = sk_MEMPACKET_value(ctx->pkts, 0)) == NULL + || thispkt->num != ctx->currpkt) { /* Probably run out of data */ BIO_set_retry_read(bio); return -1; @@ -585,7 +586,8 @@ int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum, thispkt->type = type; } - for (i = 0; (looppkt = sk_MEMPACKET_value(ctx->pkts, i)) != NULL; i++) { + for (i = 0; i < sk_MEMPACKET_num(ctx->pkts); i++) { + looppkt = sk_MEMPACKET_value(ctx->pkts, i); /* Check if we found the right place to insert this packet */ if (looppkt->num > thispkt->num) { if (sk_MEMPACKET_insert(ctx->pkts, thispkt, i) == 0) @@ -601,8 +603,9 @@ int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum, ctx->lastpkt++; do { i++; - nextpkt = sk_MEMPACKET_value(ctx->pkts, i); - if (nextpkt != NULL && nextpkt->num == ctx->lastpkt) + if (i < sk_MEMPACKET_num(ctx->pkts) + && (nextpkt = sk_MEMPACKET_value(ctx->pkts, i)) != NULL + && nextpkt->num == ctx->lastpkt) ctx->lastpkt++; else return inl; |