Fix buffer-overflow in grpc_static_mdelem_for_static_strings

pull/20109/head
Esun Kim 5 years ago
parent 06f85fc987
commit fa7bdff69f
  1. 7
      src/core/lib/transport/static_metadata.cc
  2. 3
      tools/codegen/core/gen_static_metadata.py

@ -1217,12 +1217,7 @@ static const uint16_t elem_keys[] = {
9076, 9185, 9294, 9403, 9512, 9621, 6242, 9730, 9839, 9948, 10057,
10166, 1189, 538, 10275, 10384, 212, 10493, 1195, 1196, 1197, 1198,
1080, 10602, 1843, 11365, 0, 0, 0, 1734, 0, 1850, 0,
0, 0, 356, 1627, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0};
0, 0, 356, 1627};
static const uint8_t elem_idxs[] = {
7, 8, 9, 10, 11, 12, 13, 76, 78, 71, 1, 2, 5, 6, 25, 3,
4, 66, 65, 30, 83, 62, 63, 67, 61, 73, 57, 37, 14, 19, 21, 22,

@ -627,7 +627,6 @@ def perfect_hash(keys, name):
return x + p.r[y]
return {
'PHASHRANGE': p.t - 1 + max(p.r),
'PHASHNKEYS': len(p.slots),
'pyfunc': f,
'code': """
@ -659,7 +658,7 @@ elem_keys = [
elem_hash = perfect_hash(elem_keys, 'elems')
print >> C, elem_hash['code']
keys = [0] * int(elem_hash['PHASHRANGE'])
keys = [0] * int(elem_hash['PHASHNKEYS'])
idxs = [255] * int(elem_hash['PHASHNKEYS'])
for i, k in enumerate(elem_keys):
h = elem_hash['pyfunc'](k)

Loading…
Cancel
Save