diff options
author | Craig Tiller <ctiller@google.com> | 2017-01-21 15:16:26 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-01-21 15:16:26 -0800 |
commit | 0c3fdad486d2fb23e60e1a3bf261b1846c877148 (patch) | |
tree | fe5230b0d906d540c66871bee8eeb00fb0084aca | |
parent | f28ca8ea22ec19d490129e49967024110bb3c463 (diff) |
Fix hpack fuzzer
-rw-r--r-- | src/core/lib/transport/static_metadata.c | 2 | ||||
-rwxr-xr-x | tools/codegen/core/gen_static_metadata.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/core/lib/transport/static_metadata.c b/src/core/lib/transport/static_metadata.c index 5adc3216c9..750711befd 100644 --- a/src/core/lib/transport/static_metadata.c +++ b/src/core/lib/transport/static_metadata.c @@ -474,7 +474,7 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) { if (a == -1 || b == -1) return GRPC_MDNULL; uint32_t k = (uint32_t)(a * 98 + b); uint32_t h = elems_phash(k); - return elem_keys[h] == k + return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL; diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 0374cf75a1..4703708aaa 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -461,7 +461,7 @@ print >>C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {' print >>C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' print >>C, ' uint32_t k = (uint32_t)(a * %d + b);' % len(all_strs) print >>C, ' uint32_t h = elems_phash(k);' -print >>C, ' return elem_keys[h] == k ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' +print >>C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' print >>C, '}' print >>C |