pull/5846/head
Craig Tiller 9 years ago
parent 2123974071
commit 0418d38803
  1. 10
      src/core/http/parser.c

@ -39,6 +39,8 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
extern int grpc_http_trace;
static char *buf2str(void *buffer, size_t length) { static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1); char *out = gpr_malloc(length + 1);
memcpy(out, buffer, length); memcpy(out, buffer, length);
@ -72,7 +74,7 @@ static int handle_response_line(grpc_http_parser *parser) {
return 1; return 1;
error: error:
gpr_log(GPR_ERROR, "Failed parsing response line"); if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
return 0; return 0;
} }
@ -125,7 +127,7 @@ static int handle_request_line(grpc_http_parser *parser) {
return 1; return 1;
error: error:
gpr_log(GPR_ERROR, "Failed parsing request line"); if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
return 0; return 0;
} }
@ -150,6 +152,7 @@ static int add_header(grpc_http_parser *parser) {
GPR_ASSERT(cur != end); GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') { if (*cur == ' ' || *cur == '\t') {
if (grpc_http_trace)
gpr_log(GPR_ERROR, "Continued header lines not supported yet"); gpr_log(GPR_ERROR, "Continued header lines not supported yet");
goto error; goto error;
} }
@ -158,7 +161,7 @@ static int add_header(grpc_http_parser *parser) {
cur++; cur++;
} }
if (cur == end) { 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; goto error;
} }
GPR_ASSERT(cur >= beg); GPR_ASSERT(cur >= beg);
@ -249,6 +252,7 @@ static int addbyte(grpc_http_parser *parser, uint8_t byte) {
case GRPC_HTTP_FIRST_LINE: case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS: case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) { if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
if (grpc_http_trace)
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded", gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH); GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return 0; return 0;

Loading…
Cancel
Save