#include <haproxy/buf-t.h>
#include <haproxy/list.h>
#include <haproxy/quic_stream-t.h>
+#include <haproxy/quic_token.h>
extern struct pool_head *pool_head_quic_frame;
extern struct pool_head *pool_head_qf_crypto;
struct qf_new_token {
uint64_t len;
- const unsigned char *data;
+ unsigned char data[QUIC_TOKEN_LEN];
};
struct qf_stream {
#error "Must define USE_OPENSSL"
#endif
+#include <haproxy/openssl-compat.h>
#if defined(OPENSSL_IS_AWSLC)
#include <openssl/chacha.h>
#endif
#include <haproxy/buf-t.h>
#include <haproxy/ncbuf-t.h>
#include <haproxy/quic_ack-t.h>
-#include <haproxy/openssl-compat.h>
/* Use EVP_CIPHER or EVP_AEAD API depending on the library */
#if defined(OPENSSL_IS_AWSLC)
return 1;
}
-/* Encode a NEW_TOKEN frame at <pos> buffer position.
+/* Server only function.
+ * Encode a NEW_TOKEN frame at <pos> buffer position.
* Returns 1 if succeeded (enough room at <pos> buffer position to encode the frame), 0 if not.
*/
static int quic_build_new_token_frame(unsigned char **pos, const unsigned char *end,
return 1;
}
-/* Parse a NEW_TOKEN frame at <pos> buffer position with <end> as end into <frm> frame.
+/* Client only function.
+ * Parse a NEW_TOKEN frame at <pos> buffer position with <end> as end into <frm> frame.
* Return 1 if succeeded (enough room at <pos> buffer position to parse this frame), 0 if not.
*/
static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn *qc,
{
struct qf_new_token *new_token_frm = &frm->new_token;
- if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len)
+ if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len ||
+ sizeof(new_token_frm->data) < new_token_frm->len)
return 0;
- new_token_frm->data = *pos;
+ memcpy(new_token_frm->data, *pos, new_token_frm->len);
*pos += new_token_frm->len;
return 1;