Skip to content

Commit c0845ad

Browse files
Fix crash in tls_on_send_alert.
We should not set `tls_on_send_alert` callback for HTTP1.
1 parent 78236a2 commit c0845ad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fw/tls.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ tfw_tls_on_send_alert(void *conn, struct sk_buff **skb_head)
525525
{
526526
TfwH2Ctx *ctx;
527527

528+
BUG_ON(TFW_CONN_PROTO((TfwConn *)conn) != TFW_FSM_H2);
528529
ctx = tfw_h2_context_safe((TfwConn *)conn);
529530
if (!ctx)
530531
return 0;
@@ -620,7 +621,10 @@ tfw_tls_send(TlsCtx *tls, struct sg_table *sgt)
620621
io->alert[0] == TTLS_ALERT_LEVEL_FATAL)) {
621622
TFW_CONN_TYPE(((TfwConn *)conn)) |= Conn_Stop;
622623
flags |= tfw_tls_close_msg_flags(io);
623-
TFW_SKB_CB(io->skb_list)->on_send = tfw_tls_on_send_alert;
624+
if (TFW_CONN_PROTO((TfwConn *)conn) == TFW_FSM_H2) {
625+
TFW_SKB_CB(io->skb_list)->on_send =
626+
tfw_tls_on_send_alert;
627+
}
624628
}
625629

626630
r = ss_send(conn->cli_conn.sk, &io->skb_list, flags);

0 commit comments

Comments
 (0)