Skip to content

Commit 96c254f

Browse files
a-denoyellecapflam
authored andcommitted
BUG/MINOR: mux-quic: fix crash on qcs SD alloc failure
Since the following commit, sedesc are created since QCS instantiation in qcs_new(). 086e510 BUG/MEDIUM: mux-quic: Create sedesc in same time of the QUIC stream However, sedesc is initialized before other QCS mandatory fields. If sedesc allocation fails, a crash would occur on qcs_free() invocation for QCS early release. To fix this, delay sedesc allocation until function end. This bug was detected using -dMfail. This should be backported up to 2.6. (cherry picked from commit 3aded1d) Signed-off-by: Christopher Faulet <[email protected]>
1 parent 5ab8106 commit 96c254f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/mux_quic.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,6 @@ static struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
104104
qcs->st = QC_SS_IDLE;
105105
qcs->ctx = NULL;
106106

107-
qcs->sd = sedesc_new();
108-
if (!qcs->sd)
109-
goto err;
110-
qcs->sd->se = qcs;
111-
qcs->sd->conn = qcc->conn;
112-
se_fl_set(qcs->sd, SE_FL_T_MUX | SE_FL_ORPHAN | SE_FL_NOT_FIRST);
113-
se_expect_no_data(qcs->sd);
114-
115-
if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_QUIC_SND))
116-
se_fl_set(qcs->sd, SE_FL_MAY_FASTFWD_CONS);
117-
118107
/* App callback attach may register the stream for http-request wait.
119108
* These fields must be initialed before.
120109
*/
@@ -159,6 +148,17 @@ static struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
159148

160149
qcs->err = 0;
161150

151+
qcs->sd = sedesc_new();
152+
if (!qcs->sd)
153+
goto err;
154+
qcs->sd->se = qcs;
155+
qcs->sd->conn = qcc->conn;
156+
se_fl_set(qcs->sd, SE_FL_T_MUX | SE_FL_ORPHAN | SE_FL_NOT_FIRST);
157+
se_expect_no_data(qcs->sd);
158+
159+
if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_QUIC_SND))
160+
se_fl_set(qcs->sd, SE_FL_MAY_FASTFWD_CONS);
161+
162162
/* Allocate transport layer stream descriptor. Only needed for TX. */
163163
if (!quic_stream_is_uni(id) || !quic_stream_is_remote(qcc, id)) {
164164
struct quic_conn *qc = qcc->conn->handle.qc;

0 commit comments

Comments
 (0)