Skip to content

Commit

Permalink
Fix function that checks validity of handshake packets
Browse files Browse the repository at this point in the history
When Initial and 0-RTT packets are coalesced, they can be 1200
*together*.  lsquic_is_valid_hs_packet() should use the datagram
  • Loading branch information
Dmitri Tikhonov committed Oct 8, 2020
1 parent 6eec0a7 commit e0a487c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion include/lsquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,8 @@ lsquic_get_h3_alpns (unsigned versions);
* been established: it will return incorrect result.
*/
int
lsquic_is_valid_hs_packet (lsquic_engine_t *, const unsigned char *, size_t);
lsquic_is_valid_hs_packet (lsquic_engine_t *, const unsigned char *,
size_t bufsz, size_t packet_in_sz);

/**
* Parse cid from packet stored in `buf' and store it to `cid'. Returns 0
Expand Down
6 changes: 3 additions & 3 deletions src/liblsquic/lsquic_hspack_valid.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ is_valid_gquic_hs_packet (const unsigned char *buf, size_t bufsz,

int
lsquic_is_valid_hs_packet (struct lsquic_engine *engine,
const unsigned char *buf, size_t bufsz)
const unsigned char *buf, size_t bufsz, size_t packet_in_sz)
{
lsquic_ver_tag_t tag;
int is_valid;
Expand All @@ -104,7 +104,7 @@ lsquic_is_valid_hs_packet (struct lsquic_engine *engine,
case 0x80|0x00|0x20|0x10|0x08:
case 0x80|0x40|0x20|0x10|0x00:
case 0x80|0x00|0x20|0x10|0x00:
is_valid = bufsz >= IQUIC_MIN_INIT_PACKET_SZ
is_valid = packet_in_sz >= IQUIC_MIN_INIT_PACKET_SZ
&& lsquic_is_valid_iquic_hs_packet(buf, bufsz, &tag);
break;
/* 1X00 XGGG: ID-22 long header */
Expand All @@ -122,7 +122,7 @@ lsquic_is_valid_hs_packet (struct lsquic_engine *engine,
case 0x80|0x00|0x20|0x00|0x08:
case 0x80|0x40|0x20|0x00|0x00:
case 0x80|0x00|0x20|0x00|0x00:
is_valid = bufsz >= IQUIC_MIN_INIT_PACKET_SZ
is_valid = packet_in_sz >= IQUIC_MIN_INIT_PACKET_SZ
&& lsquic_is_valid_ietf_v1_or_Q046plus_hs_packet(buf, bufsz, &tag);
break;
/* 01XX XGGG: ID-22 short header */
Expand Down

0 comments on commit e0a487c

Please sign in to comment.