diff options
author | Alistair Veitch <aveitch@google.com> | 2016-07-26 10:30:36 -0700 |
---|---|---|
committer | Alistair Veitch <aveitch@google.com> | 2016-07-26 10:30:36 -0700 |
commit | 8c7618e88d6a272e17fc67072f6700e0dc4080ab (patch) | |
tree | 893bd4c5ea5ff6505bdbcd91fdba361d0f75fde1 /src/core/ext/census | |
parent | 2ea5e3d3969a6154a863c8fe0b898f71b5042cff (diff) |
Fix memory overwrite in proto decding; fix test for windows
Diffstat (limited to 'src/core/ext/census')
-rw-r--r-- | src/core/ext/census/resource.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/ext/census/resource.c b/src/core/ext/census/resource.c index 905de2d63d..63bfb75b47 100644 --- a/src/core/ext/census/resource.c +++ b/src/core/ext/census/resource.c @@ -156,9 +156,11 @@ static bool validate_units_helper(pb_istream_t *stream, int *count, gpr_free(*bup); } *bup = new_bup; - if (!pb_decode_varint(stream, (uint64_t *)(*bup + *count - 1))) { + uint64_t value; + if (!pb_decode_varint(stream, &value)) { return false; } + *(*bup + *count - 1) = (google_census_Resource_BasicUnit)value; } return true; } @@ -290,7 +292,7 @@ int32_t define_resource(const resource *base) { resources[id]->name = gpr_malloc(len); memcpy(resources[id]->name, base->name, len); if (base->description) { - len = strlen(base->description); + len = strlen(base->description) + 1; resources[id]->description = gpr_malloc(len); memcpy(resources[id]->description, base->description, len); } |