aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/census
diff options
context:
space:
mode:
authorGravatar Alistair Veitch <aveitch@google.com>2016-07-26 10:30:36 -0700
committerGravatar Alistair Veitch <aveitch@google.com>2016-07-26 10:30:36 -0700
commit8c7618e88d6a272e17fc67072f6700e0dc4080ab (patch)
tree893bd4c5ea5ff6505bdbcd91fdba361d0f75fde1 /src/core/ext/census
parent2ea5e3d3969a6154a863c8fe0b898f71b5042cff (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.c6
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);
}