summaryrefslogtreecommitdiffstats
path: root/src/quic_tp.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/quic_tp.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/quic_tp.c b/src/quic_tp.c
index caf48ce..08d24b2 100644
--- a/src/quic_tp.c
+++ b/src/quic_tp.c
@@ -171,23 +171,23 @@ static int quic_transport_param_dec_version_info(struct tp_version_information *
const unsigned char *end, int server)
{
size_t tp_len = end - *buf;
- const uint32_t *ver, *others;
+ const unsigned char *ver, *others;
/* <tp_len> must be a multiple of sizeof(uint32_t) */
if (tp_len < sizeof tp->chosen || (tp_len & 0x3))
return 0;
- tp->chosen = ntohl(*(uint32_t *)*buf);
+ tp->chosen = ntohl(read_u32(*buf));
/* Must not be null */
if (!tp->chosen)
return 0;
*buf += sizeof tp->chosen;
- others = (const uint32_t *)*buf;
+ others = *buf;
/* Others versions must not be null */
- for (ver = others; ver < (const uint32_t *)end; ver++) {
- if (!*ver)
+ for (ver = others; ver < end; ver += 4) {
+ if (!read_u32(ver))
return 0;
}
@@ -195,19 +195,19 @@ static int quic_transport_param_dec_version_info(struct tp_version_information *
/* TODO: not supported */
return 0;
- for (ver = others; ver < (const uint32_t *)end; ver++) {
+ for (ver = others; ver < end; ver += 4) {
if (!tp->negotiated_version) {
int i;
for (i = 0; i < quic_versions_nb; i++) {
- if (ntohl(*ver) == quic_versions[i].num) {
+ if (ntohl(read_u32(ver)) == quic_versions[i].num) {
tp->negotiated_version = &quic_versions[i];
break;
}
}
}
- if (preferred_version && ntohl(*ver) == preferred_version->num) {
+ if (preferred_version && ntohl(read_u32(ver)) == preferred_version->num) {
tp->negotiated_version = preferred_version;
goto out;
}
@@ -565,7 +565,7 @@ int quic_transport_params_encode(unsigned char *buf,
p->active_connection_id_limit))
return 0;
- if (!quic_transport_param_enc_version_info(&pos, end, chosen_version, server))
+ if (chosen_version && !quic_transport_param_enc_version_info(&pos, end, chosen_version, server))
return 0;
return pos - head;