mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
h2: defend against no NUL possible in log
This commit is contained in:
parent
924bd78085
commit
9a7ce85001
3 changed files with 14 additions and 3 deletions
|
@ -1391,8 +1391,15 @@ int lws_add_http2_header_by_name(struct lws *wsi, const unsigned char *name,
|
|||
{
|
||||
int len;
|
||||
|
||||
lwsl_header("%s: %p %s:%s (len %d)\n", __func__, *p, name, value,
|
||||
length);
|
||||
#if defined(_DEBUG)
|
||||
/* value does not have to be NUL-terminated... %.*s not available on
|
||||
* all platforms */
|
||||
lws_strnncpy((char *)*p, (const char *)value, length,
|
||||
lws_ptr_diff(end, (*p)));
|
||||
|
||||
lwsl_header("%s: %p %s:%s (len %d)\n", __func__, *p, name,
|
||||
(const char *)*p, length);
|
||||
#endif
|
||||
|
||||
len = (int)strlen((char *)name);
|
||||
if (len)
|
||||
|
|
|
@ -2040,6 +2040,10 @@ lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t inlen,
|
|||
h2n->swsi->http.rx_content_remain <
|
||||
inlen + 1 && /* last */
|
||||
h2n->inside < h2n->length) {
|
||||
lwsl_warn("%s: rem %d, inlen %d\n",
|
||||
__func__,
|
||||
(int)h2n->swsi->http.rx_content_remain,
|
||||
(int)inlen + 1);
|
||||
/* unread data in frame */
|
||||
lws_h2_goaway(wsi,
|
||||
H2_ERR_PROTOCOL_ERROR,
|
||||
|
|
|
@ -2334,7 +2334,7 @@ lws_http_transaction_completed(struct lws *wsi)
|
|||
peer[0] = '\0';
|
||||
#endif
|
||||
peer[sizeof(peer) - 1] = '\0';
|
||||
lwsl_notice("%s: (from %s) ignoring, ah parsing incomplete\n",
|
||||
lwsl_info("%s: (from %s) ignoring, ah parsing incomplete\n",
|
||||
__func__, peer);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue