Skip to content

Commit

Permalink
QUIC: Check block_until_pred return value in shutdown (coverity)
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #21565)
  • Loading branch information
hlandau committed Aug 10, 2023
1 parent a2d4915 commit 23406e3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions ssl/quic/quic_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static int ossl_unused expect_quic_with_stream_lock(const SSL *s, int remote_ini
goto err;
}

return 1; /* lock held */
return 1; /* coverity[missing_unlock]: lock held */

err:
quic_unlock(ctx->qc);
Expand Down Expand Up @@ -1186,10 +1186,15 @@ int ossl_quic_conn_shutdown(SSL *s, uint64_t flags,
qc_shutdown_flush_init(ctx.qc);

if (!qc_shutdown_flush_finished(ctx.qc)) {
if (qc_blocking_mode(ctx.qc))
block_until_pred(ctx.qc, quic_shutdown_flush_wait, ctx.qc, 0);
else
if (qc_blocking_mode(ctx.qc)) {
ret = block_until_pred(ctx.qc, quic_shutdown_flush_wait, ctx.qc, 0);
if (ret < 1) {
ret = 0;
goto err;
}
} else {
ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(ctx.qc->ch), 0);
}
}

if (!qc_shutdown_flush_finished(ctx.qc)) {
Expand All @@ -1211,12 +1216,18 @@ int ossl_quic_conn_shutdown(SSL *s, uint64_t flags,
}

/* Phase 3: Terminating Wait Time */
if (qc_blocking_mode(ctx.qc) && (flags & SSL_SHUTDOWN_FLAG_RAPID) == 0)
block_until_pred(ctx.qc, quic_shutdown_wait, ctx.qc, 0);
else
if (qc_blocking_mode(ctx.qc) && (flags & SSL_SHUTDOWN_FLAG_RAPID) == 0) {
ret = block_until_pred(ctx.qc, quic_shutdown_wait, ctx.qc, 0);
if (ret < 1) {
ret = 0;
goto err;
}
} else {
ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(ctx.qc->ch), 0);
}

ret = ossl_quic_channel_is_terminated(ctx.qc->ch);
err:
quic_unlock(ctx.qc);
return ret;
}
Expand Down

0 comments on commit 23406e3

Please sign in to comment.