Skip to content
Snippets Groups Projects
Commit 5ce5d825 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

Merge pull request #5897 from ctiller/fix_time

Fix timeout decoding logic for times that become infinite
parents 314575f5 e07c3688
No related branches found
No related tags found
No related merge requests found
......@@ -150,7 +150,7 @@ int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
/* spec allows max. 8 digits, but we allow values up to 1,000,000,000 */
if (x >= (100 * 1000 * 1000)) {
if (x != (100 * 1000 * 1000) || digit != 0) {
*timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
*timeout = gpr_inf_future(GPR_TIMESPAN);
return 1;
}
}
......
......@@ -36,11 +36,11 @@
#include <stdio.h>
#include <string.h>
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
#include "src/core/support/string.h"
#include "test/core/util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
......@@ -128,11 +128,10 @@ void test_decoding(void) {
decode_suite('H', gpr_time_from_hours);
assert_decodes_as("1000000000S",
gpr_time_from_seconds(1000 * 1000 * 1000, GPR_TIMESPAN));
assert_decodes_as("1000000000000000000000u",
gpr_inf_future(GPR_CLOCK_REALTIME));
assert_decodes_as("1000000001S", gpr_inf_future(GPR_CLOCK_REALTIME));
assert_decodes_as("2000000001S", gpr_inf_future(GPR_CLOCK_REALTIME));
assert_decodes_as("9999999999S", gpr_inf_future(GPR_CLOCK_REALTIME));
assert_decodes_as("1000000000000000000000u", gpr_inf_future(GPR_TIMESPAN));
assert_decodes_as("1000000001S", gpr_inf_future(GPR_TIMESPAN));
assert_decodes_as("2000000001S", gpr_inf_future(GPR_TIMESPAN));
assert_decodes_as("9999999999S", gpr_inf_future(GPR_TIMESPAN));
}
void test_decoding_fails(void) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment