Fix binlog crash on bad stream frame
@@ -82,18 +82,21 @@ static const uint8_t* picoquic_log_stream_frame(FILE* f, const uint8_t* bytes, c
bytes = picoquic_log_varint_skip(bytes, bytes_max); /* offset */
}
+ if (bytes != NULL) {
if ((ftype & 2) != 0) {
bytes = picoquic_log_length(bytes, bytes_max, &length); /* length */
has_length = 1;
- } else {
+ }
+ else {
length = bytes_max - bytes;
}
+ }
+ if (bytes != NULL) {
if (length < extra_bytes) {
/* Add up to 8 bytes of content that can be documented in the qlog */
extra_bytes = length;
}
-
if (has_length) {
picoquic_binlog_frame(f, bytes_begin, bytes + extra_bytes);
}
@@ -114,6 +117,15 @@ static const uint8_t* picoquic_log_stream_frame(FILE* f, const uint8_t* bytes, c
}
bytes = picoquic_log_fixed_skip(bytes, bytes_max, length);
+ }
+ else {
+ /* Cautiously log the beginning of the erroneous frame */
+ length = bytes_max - bytes_begin;
+ if (length > 26) {
+ length = 26;
+ }
+ picoquic_binlog_frame(f, bytes_begin, bytes_begin + length);
+ }
return bytes;
}
