ncid_frm->seq_num = src->seq_num.key;
ncid_frm->retire_prior_to = src->retire_prior_to;
ncid_frm->cid.len = src->cid.len;
- ncid_frm->cid.data = src->cid.data;
- ncid_frm->stateless_reset_token = src->stateless_reset_token;
+ memcpy(ncid_frm->cid.data, src->cid.data, src->cid.len);
+ memcpy(ncid_frm->stateless_reset_token, src->stateless_reset_token,
+ QUIC_STATELESS_RESET_TOKEN_LEN);
}
#endif /* USE_QUIC */
#include <import/ebtree-t.h>
#include <haproxy/buf-t.h>
#include <haproxy/list.h>
+#include <haproxy/quic_cid-t.h>
+#include <haproxy/quic_tp-t.h>
#include <haproxy/quic_token.h>
extern struct pool_head *pool_head_quic_frame;
uint64_t limit;
};
+/* The CID and the token are stored in the frame, because a frame which is
+ * waiting to be sent or retransmitted must not depend on the lifetime of the
+ * quic_connection_id it was built from: the peer may retire it at any time.
+ */
struct qf_new_connection_id {
uint64_t seq_num;
uint64_t retire_prior_to;
struct {
unsigned char len;
- const unsigned char *data;
+ unsigned char data[QUIC_CID_MAXLEN];
} cid;
- const unsigned char *stateless_reset_token;
+ unsigned char stateless_reset_token[QUIC_STATELESS_RESET_TOKEN_LEN];
};
struct qf_retire_connection_id {
return 0;
ncid_frm->cid.len = *(*pos)++;
- if (end - *pos < ncid_frm->cid.len + QUIC_STATELESS_RESET_TOKEN_LEN)
+ /* RFC 9000 19.15. NEW_CONNECTION_ID Frames:
+ * Values less than 1 and greater than 20 are invalid and MUST be
+ * treated as a connection error of type FRAME_ENCODING_ERROR.
+ */
+ if (ncid_frm->cid.len > QUIC_CID_MAXLEN ||
+ end - *pos < ncid_frm->cid.len + QUIC_STATELESS_RESET_TOKEN_LEN)
return 0;
if (ncid_frm->cid.len) {
- ncid_frm->cid.data = *pos;
+ memcpy(ncid_frm->cid.data, *pos, ncid_frm->cid.len);
*pos += ncid_frm->cid.len;
}
- ncid_frm->stateless_reset_token = *pos;
+ memcpy(ncid_frm->stateless_reset_token, *pos, QUIC_STATELESS_RESET_TOKEN_LEN);
*pos += QUIC_STATELESS_RESET_TOKEN_LEN;
return 1;