aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.c38
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.c24
-rw-r--r--src/core/lib/http/parser.c16
-rw-r--r--src/core/lib/json/json_reader.c7
4 files changed, 57 insertions, 28 deletions
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c
index 58e90f98f2..ec3387efb8 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c
@@ -52,6 +52,8 @@
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/support/string.h"
+extern int grpc_http_trace;
+
typedef enum {
NOT_BINARY,
B64_BYTE0,
@@ -723,7 +725,9 @@ static int finish_indexed_field(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (md == NULL) {
- gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
+ if (grpc_http_trace) {
+ gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
+ }
return 0;
}
GRPC_MDELEM_REF(md);
@@ -919,7 +923,9 @@ static int parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser *p,
/* finish parsing a max table size change */
static int finish_max_tbl_size(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end) {
- gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
+ if (grpc_http_trace) {
+ gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
+ }
return grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index) &&
parse_begin(p, cur, end);
}
@@ -960,7 +966,9 @@ static int parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
static int parse_illegal_op(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end) {
GPR_ASSERT(cur != end);
- gpr_log(GPR_DEBUG, "Illegal hpack op code %d", *cur);
+ if (grpc_http_trace) {
+ gpr_log(GPR_DEBUG, "Illegal hpack op code %d", *cur);
+ }
return parse_error(p, cur, end);
}
@@ -1069,10 +1077,12 @@ static int parse_value4(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
}
error:
- gpr_log(GPR_ERROR,
- "integer overflow in hpack integer decoding: have 0x%08x, "
- "got byte 0x%02x on byte 5",
- *p->parsing.value, *cur);
+ if (grpc_http_trace) {
+ gpr_log(GPR_ERROR,
+ "integer overflow in hpack integer decoding: have 0x%08x, "
+ "got byte 0x%02x on byte 5",
+ *p->parsing.value, *cur);
+ }
return parse_error(p, cur, end);
}
@@ -1094,10 +1104,12 @@ static int parse_value5up(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
return parse_next(p, cur + 1, end);
}
- gpr_log(GPR_ERROR,
- "integer overflow in hpack integer decoding: have 0x%08x, "
- "got byte 0x%02x sometime after byte 5",
- *p->parsing.value, *cur);
+ if (grpc_http_trace) {
+ gpr_log(GPR_ERROR,
+ "integer overflow in hpack integer decoding: have 0x%08x, "
+ "got byte 0x%02x sometime after byte 5",
+ *p->parsing.value, *cur);
+ }
return parse_error(p, cur, end);
}
@@ -1329,7 +1341,9 @@ static is_binary_header is_binary_literal_header(grpc_chttp2_hpack_parser *p) {
static is_binary_header is_binary_indexed_header(grpc_chttp2_hpack_parser *p) {
grpc_mdelem *elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (!elem) {
- gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
+ if (grpc_http_trace) {
+ gpr_log(GPR_ERROR, "Invalid HPACK index received: %d", p->index);
+ }
return ERROR_HEADER;
}
return grpc_is_binary_header(
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.c b/src/core/ext/transport/chttp2/transport/hpack_table.c
index d02f4ddc61..67cd1bb10a 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.c
@@ -41,6 +41,8 @@
#include "src/core/lib/support/murmur_hash.h"
+extern int grpc_http_trace;
+
static struct {
const char *key;
const char *value;
@@ -264,12 +266,16 @@ int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
return 1;
}
if (bytes > tbl->max_bytes) {
- gpr_log(GPR_ERROR,
- "Attempt to make hpack table %d bytes when max is %d bytes", bytes,
- tbl->max_bytes);
+ if (grpc_http_trace) {
+ gpr_log(GPR_ERROR,
+ "Attempt to make hpack table %d bytes when max is %d bytes",
+ bytes, tbl->max_bytes);
+ }
return 0;
}
- gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
+ if (grpc_http_trace) {
+ gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
+ }
while (tbl->mem_used > bytes) {
evict1(tbl);
}
@@ -293,10 +299,12 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
if (tbl->current_table_bytes > tbl->max_bytes) {
- gpr_log(GPR_ERROR,
- "HPACK max table size reduced to %d but not reflected by hpack "
- "stream (still at %d)",
- tbl->max_bytes, tbl->current_table_bytes);
+ if (grpc_http_trace) {
+ gpr_log(GPR_ERROR,
+ "HPACK max table size reduced to %d but not reflected by hpack "
+ "stream (still at %d)",
+ tbl->max_bytes, tbl->current_table_bytes);
+ }
return 0;
}
diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c
index 5d4e304615..2782ad758e 100644
--- a/src/core/lib/http/parser.c
+++ b/src/core/lib/http/parser.c
@@ -39,6 +39,8 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
+extern int grpc_http_trace;
+
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
memcpy(out, buffer, length);
@@ -72,7 +74,7 @@ static int handle_response_line(grpc_http_parser *parser) {
return 1;
error:
- gpr_log(GPR_ERROR, "Failed parsing response line");
+ if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
return 0;
}
@@ -125,7 +127,7 @@ static int handle_request_line(grpc_http_parser *parser) {
return 1;
error:
- gpr_log(GPR_ERROR, "Failed parsing request line");
+ if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
return 0;
}
@@ -150,7 +152,8 @@ static int add_header(grpc_http_parser *parser) {
GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') {
- gpr_log(GPR_ERROR, "Continued header lines not supported yet");
+ if (grpc_http_trace)
+ gpr_log(GPR_ERROR, "Continued header lines not supported yet");
goto error;
}
@@ -158,7 +161,7 @@ static int add_header(grpc_http_parser *parser) {
cur++;
}
if (cur == end) {
- gpr_log(GPR_ERROR, "Didn't find ':' in header string");
+ if (grpc_http_trace) gpr_log(GPR_ERROR, "Didn't find ':' in header string");
goto error;
}
GPR_ASSERT(cur >= beg);
@@ -249,8 +252,9 @@ static int addbyte(grpc_http_parser *parser, uint8_t byte) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
- gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
- GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
+ if (grpc_http_trace)
+ gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
+ GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return 0;
}
parser->cur_line[parser->cur_line_length] = byte;
diff --git a/src/core/lib/json/json_reader.c b/src/core/lib/json/json_reader.c
index 0807f029ce..4cff13dff1 100644
--- a/src/core/lib/json/json_reader.c
+++ b/src/core/lib/json/json_reader.c
@@ -280,13 +280,14 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
break;
case GRPC_JSON_STATE_OBJECT_KEY_STRING:
- GPR_ASSERT(reader->unicode_high_surrogate == 0);
+ if (reader->unicode_high_surrogate != 0)
+ return GRPC_JSON_PARSE_ERROR;
if (c == '"') {
reader->state = GRPC_JSON_STATE_OBJECT_KEY_END;
json_reader_set_key(reader);
json_reader_string_clear(reader);
} else {
- if (c <= 0x001f) return GRPC_JSON_PARSE_ERROR;
+ if (c < 32) return GRPC_JSON_PARSE_ERROR;
json_reader_string_add_char(reader, c);
}
break;
@@ -362,6 +363,8 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) {
reader->in_object = 0;
reader->in_array = 1;
break;
+ default:
+ return GRPC_JSON_PARSE_ERROR;
}
break;