Skip to content

Commit 83bd975

Browse files
a-denoyellecapflam
authored andcommitted
BUG/MINOR: h3: fix BUG_ON() crash on control stream alloc failure
BUG_ON() from qcc_set_error() is triggered on HTTP/3 control stream allocation failure. This is caused because both h3_finalize() and qcc_init_stream_local() call qcc_set_error() which is forbidden to prevent error code erasure. Fix this by removing qcc_set_error() invocation from h3_finalize() on allocation failure. Note that this function is still responsible to use it on SETTING frame emission failure. This was detected using -dMfail. This must be backported up to 3.0. (cherry picked from commit 5718c67) Signed-off-by: Christopher Faulet <[email protected]>
1 parent 96c254f commit 83bd975

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/h3.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,20 +2378,23 @@ static int h3_finalize(void *ctx)
23782378

23792379
qcs = qcc_init_stream_local(qcc, 0);
23802380
if (!qcs) {
2381+
/* Error must be set by qcc_init_stream_local(). */
2382+
BUG_ON(!(qcc->flags & QC_CF_ERRL));
23812383
TRACE_ERROR("cannot init control stream", H3_EV_H3C_NEW, qcc->conn);
23822384
goto err;
23832385
}
23842386

23852387
h3c->ctrl_strm = qcs;
23862388

2387-
if (h3_control_send(qcs, h3c) < 0)
2389+
if (h3_control_send(qcs, h3c) < 0) {
2390+
qcc_set_error(qcc, H3_ERR_INTERNAL_ERROR, 1);
23882391
goto err;
2392+
}
23892393

23902394
TRACE_LEAVE(H3_EV_H3C_NEW, qcc->conn);
23912395
return 0;
23922396

23932397
err:
2394-
qcc_set_error(qcc, H3_ERR_INTERNAL_ERROR, 1);
23952398
TRACE_DEVEL("leaving on error", H3_EV_H3C_NEW, qcc->conn);
23962399
return 1;
23972400
}

src/mux_quic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ struct qcs *qcc_init_stream_local(struct qcc *qcc, int bidi)
617617

618618
qcs = qcs_new(qcc, *next, type);
619619
if (!qcs) {
620-
TRACE_LEAVE(QMUX_EV_QCS_NEW, qcc->conn);
621620
qcc_set_error(qcc, QC_ERR_INTERNAL_ERROR, 0);
621+
TRACE_DEVEL("leaving on error", QMUX_EV_QCS_NEW, qcc->conn);
622622
return NULL;
623623
}
624624

0 commit comments

Comments
 (0)