Release 2.6.6

- [BUGFIX] Using HTTP/3 to HTTP/1.x converter.
- [BUGFIX] Truncate log messages instead of throwing them away.
This commit is contained in:
Dmitri Tikhonov 2019-11-20 11:43:10 -05:00
parent be8bc27c5b
commit 55f8042d41
5 changed files with 98 additions and 10 deletions

View file

@ -1,3 +1,8 @@
2019-11-20
- 2.6.6
- [BUGFIX] Using HTTP/3 to HTTP/1.x converter.
- [BUGFIX] Truncate log messages instead of throwing them away.
2019-11-15
- 2.6.5
- [BUGFIX] High priority buffered packet queue length.

View file

@ -25,7 +25,7 @@ extern "C" {
#define LSQUIC_MAJOR_VERSION 2
#define LSQUIC_MINOR_VERSION 6
#define LSQUIC_PATCH_VERSION 5
#define LSQUIC_PATCH_VERSION 6
/**
* Engine flags:

View file

@ -20,7 +20,12 @@
#include "lsquic_logger.h"
#define MAX_LINE_LEN 8192
#define FORMAT_PROBLEM(lb, len, max) (((ssize_t)lb < 0) || ((ssize_t)lb + (ssize_t)len >= (ssize_t)max))
/* Expanded TRUNC_FMT should not exceed TRUNC_SZ bytes. At the same time,
* TRUNC_SZ should be significantly smaller than MAX_LINE_LEN.
*/
#define TRUNC_FMT "<truncated, need %d bytes>"
#define TRUNC_SZ 40
#define FORMAT_PROBLEM(lb, len, max) ((lb < 0) || (lb + len >= max))
/* TODO: display GQUIC CIDs in Chrome-compatible format */
@ -241,7 +246,7 @@ lsquic_logger_log3 (enum lsq_log_level log_level,
const int saved_errno = errno;
char cidbuf_[MAX_CID_LEN * 2 + 1];
size_t len = 0;
size_t lb;
int lb;
size_t max = MAX_LINE_LEN;
char buf[MAX_LINE_LEN];
@ -262,6 +267,11 @@ lsquic_logger_log3 (enum lsq_log_level log_level,
va_start(ap, fmt);
lb = vsnprintf(buf + len, max - len, fmt, ap);
va_end(ap);
if (lb > 0 && (size_t) lb >= max - len && max - len >= TRUNC_SZ)
{
len = max - TRUNC_SZ;
lb = snprintf(buf + max - TRUNC_SZ, TRUNC_SZ, TRUNC_FMT, lb);
}
if (FORMAT_PROBLEM(lb, len, max))
goto end;
len += lb;
@ -283,7 +293,7 @@ lsquic_logger_log2 (enum lsq_log_level log_level,
const int saved_errno = errno;
char cidbuf_[MAX_CID_LEN * 2 + 1];
size_t len = 0;
size_t lb;
int lb;
size_t max = MAX_LINE_LEN;
char buf[MAX_LINE_LEN];
@ -304,6 +314,11 @@ lsquic_logger_log2 (enum lsq_log_level log_level,
va_start(ap, fmt);
lb = vsnprintf(buf + len, max - len, fmt, ap);
va_end(ap);
if (lb > 0 && (size_t) lb >= max - len && max - len >= TRUNC_SZ)
{
len = max - TRUNC_SZ;
lb = snprintf(buf + max - TRUNC_SZ, TRUNC_SZ, TRUNC_FMT, lb);
}
if (FORMAT_PROBLEM(lb, len, max))
goto end;
len += lb;
@ -324,7 +339,7 @@ lsquic_logger_log1 (enum lsq_log_level log_level,
{
const int saved_errno = errno;
size_t len = 0;
size_t lb;
int lb;
size_t max = MAX_LINE_LEN;
char buf[MAX_LINE_LEN];
@ -344,6 +359,11 @@ lsquic_logger_log1 (enum lsq_log_level log_level,
va_start(ap, fmt);
lb = vsnprintf(buf + len, max - len, fmt, ap);
va_end(ap);
if (lb > 0 && (size_t) lb >= max - len && max - len >= TRUNC_SZ)
{
len = max - TRUNC_SZ;
lb = snprintf(buf + max - TRUNC_SZ, TRUNC_SZ, TRUNC_FMT, lb);
}
if (FORMAT_PROBLEM(lb, len, max))
goto end;
len += lb;
@ -362,7 +382,7 @@ lsquic_logger_log0 (enum lsq_log_level log_level, const char *fmt, ...)
{
const int saved_errno = errno;
size_t len = 0;
size_t lb;
int lb;
size_t max = MAX_LINE_LEN;
char buf[MAX_LINE_LEN];
@ -382,6 +402,11 @@ lsquic_logger_log0 (enum lsq_log_level log_level, const char *fmt, ...)
va_start(ap, fmt);
lb = vsnprintf(buf + len, max - len, fmt, ap);
va_end(ap);
if (lb > 0 && (size_t) lb >= max - len && max - len >= TRUNC_SZ)
{
len = max - TRUNC_SZ;
lb = snprintf(buf + max - TRUNC_SZ, TRUNC_SZ, TRUNC_FMT, lb);
}
if (FORMAT_PROBLEM(lb, len, max))
goto end;
len += lb;

View file

@ -1435,10 +1435,16 @@ lsquic_stream_readf (struct lsquic_stream *stream,
errno = EBADF;
return -1;
}
if ((stream->stream_flags & STREAM_FIN_REACHED)
&& 0 == (!!(stream->stream_flags & STREAM_HAVE_UH)
^ !!(stream->sm_bflags & SMBF_USE_HEADERS)))
return 0;
if (stream->stream_flags & STREAM_FIN_REACHED)
{
if (stream->sm_bflags & SMBF_USE_HEADERS)
{
if ((stream->stream_flags & STREAM_HAVE_UH) && !stream->uh)
return 0;
}
else
return 0;
}
return stream_readf(stream, readf, ctx);
}

View file

@ -52,6 +52,8 @@
#include "lsquic_enc_sess.h"
#include "lsqpack.h"
#include "lsquic_frab_list.h"
#include "lsquic_http1x_if.h"
#include "lsquic_qdec_hdl.h"
#include "lsquic_qenc_hdl.h"
#include "lsquic_varint.h"
#include "lsquic_hq.h"
@ -122,6 +124,7 @@ struct test_objs {
unsigned initial_stream_window;
enum stream_ctor_flags ctor_flags;
struct qpack_enc_hdl qeh;
struct qpack_dec_hdl qdh;
};
@ -189,6 +192,11 @@ init_test_objs (struct test_objs *tobjs, unsigned initial_conn_window,
s = lsquic_qeh_settings(&tobjs->qeh, 0, 0, 0, 0);
assert(0 == s);
tobjs->conn_pub.u.ietf.qeh = &tobjs->qeh;
tobjs->conn_pub.enpub->enp_hsi_if = lsquic_http1x_if;
s = lsquic_qdh_init(&tobjs->qdh, &tobjs->lconn, 0,
tobjs->conn_pub.enpub, 0, 0);
tobjs->conn_pub.u.ietf.qdh = &tobjs->qdh;
assert(0 == s);
}
}
@ -201,7 +209,10 @@ deinit_test_objs (struct test_objs *tobjs)
lsquic_malo_destroy(tobjs->conn_pub.packet_out_malo);
lsquic_mm_cleanup(&tobjs->eng_pub.enp_mm);
if ((1 << tobjs->lconn.cn_version) & LSQUIC_IETF_VERSIONS)
{
lsquic_qeh_cleanup(&tobjs->qeh);
lsquic_qdh_cleanup(&tobjs->qdh);
}
}
@ -583,6 +594,46 @@ test_read_headers (int ietf, int use_hset)
}
static void
test_read_headers_http1x (void)
{
struct test_objs tobjs;
struct lsquic_stream *stream;
struct stream_frame *frame;
int s;
const unsigned char headers_frame[5] = {
0x01, /* Headers frame */
0x03, /* Frame length */
0x00,
0x00,
0xC0 | 25 /* :status 200 */,
};
ssize_t nr;
unsigned char buf[0x100];
init_test_objs(&tobjs, 0x1000, 0x1000, SCF_IETF);
stream = new_stream(&tobjs, 0, 0x1000);
frame = new_frame_in(&tobjs, 0, sizeof(headers_frame), 1);
memcpy((unsigned char *) frame->data_frame.df_data, headers_frame,
sizeof(headers_frame));
s = lsquic_stream_frame_in(stream, frame);
assert(s == 0);
assert(stream->stream_flags & STREAM_FIN_REACHED);
s = lsquic_stream_readable(stream);
nr = lsquic_stream_read(stream, buf, sizeof(buf));
assert(nr > 0);
assert(nr == 19);
assert(0 == memcmp(buf, "HTTP/1.1 200 OK\r\n\r\n", nr));
lsquic_stream_destroy(stream);
deinit_test_objs(&tobjs);
}
int
main (int argc, char **argv)
{
@ -612,6 +663,7 @@ main (int argc, char **argv)
test_read_headers(0, 1);
test_read_headers(1, 0);
test_read_headers(1, 1);
test_read_headers_http1x();
return 0;
}