diff options
author | 2016-11-18 16:10:24 -0800 | |
---|---|---|
committer | 2016-11-18 16:10:24 -0800 | |
commit | 03cdd3e2de886659761878ea877f6ad5d51f6319 (patch) | |
tree | 138a626389f4e0cd9525febd81a361a381f69af3 /src/core/lib/transport/timeout_encoding.c | |
parent | 5ae3ffb3676de640598e675f2670ef8695559fbf (diff) |
Fix timeout decoding
Diffstat (limited to 'src/core/lib/transport/timeout_encoding.c')
-rw-r--r-- | src/core/lib/transport/timeout_encoding.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/lib/transport/timeout_encoding.c b/src/core/lib/transport/timeout_encoding.c index b2060be59e..0d4d7e5a7e 100644 --- a/src/core/lib/transport/timeout_encoding.c +++ b/src/core/lib/transport/timeout_encoding.c @@ -131,16 +131,15 @@ void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer) { } } -static int is_all_whitespace(const char *p) { - while (*p == ' ') p++; - return *p == 0; +static int is_all_whitespace(const char *p, const char *end) { + while (p != end && *p == ' ') p++; + return p == end; } -int grpc_http2_decode_timeout(const uint8_t *buffer, size_t length, - gpr_timespec *timeout) { +int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { int32_t x = 0; - const uint8_t *p = buffer; - const uint8_t *end = p + length; + const uint8_t *p = GRPC_SLICE_START_PTR(text); + const uint8_t *end = GRPC_SLICE_END_PTR(text); int have_digit = 0; /* skip whitespace */ for (; p != end && *p == ' '; p++) @@ -187,5 +186,5 @@ int grpc_http2_decode_timeout(const uint8_t *buffer, size_t length, return 0; } p++; - return is_all_whitespace((const char *)p); + return is_all_whitespace((const char *)p, (const char *)end); } |