aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
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 /test
parent2ea5e3d3969a6154a863c8fe0b898f71b5042cff (diff)
Fix memory overwrite in proto decding; fix test for windows
Diffstat (limited to 'test')
-rw-r--r--test/core/census/resource_test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/core/census/resource_test.c b/test/core/census/resource_test.c
index 1375d56a6b..e1556d7d7b 100644
--- a/test/core/census/resource_test.c
+++ b/test/core/census/resource_test.c
@@ -66,10 +66,10 @@ static void test_empty_definition() {
static int32_t define_resource_from_file(const char *file) {
#define BUF_SIZE 512
uint8_t buffer[BUF_SIZE];
- FILE *input = fopen(file, "r");
+ FILE *input = fopen(file, "rb");
GPR_ASSERT(input != NULL);
size_t nbytes = fread(buffer, 1, BUF_SIZE, input);
- GPR_ASSERT(nbytes != 0 && nbytes < BUF_SIZE);
+ GPR_ASSERT(nbytes != 0 && nbytes < BUF_SIZE && feof(input) && !ferror(input));
int32_t rid = census_define_resource(buffer, nbytes);
GPR_ASSERT(fclose(input) == 0);
return rid;