From 2e33ab26df4356c40a4c9b636f99a7bfbdc7838c Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 10 Jan 2018 13:27:45 +0000 Subject: [PATCH] Zero-initialise stack-allocated objects in hstox driver. These potentially cause uninitialised reads on some platforms or msgpack library versions. --- testing/hstox/driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/hstox/driver.c b/testing/hstox/driver.c index 33823277..add43901 100644 --- a/testing/hstox/driver.c +++ b/testing/hstox/driver.c @@ -80,7 +80,7 @@ static int write_sample_input(msgpack_object req) check_return(E_WRITE, ftruncate(fd, 0)); - msgpack_sbuffer sbuf __attribute__((__cleanup__(msgpack_sbuffer_destroy))); + msgpack_sbuffer sbuf __attribute__((__cleanup__(msgpack_sbuffer_destroy))) = {0}; msgpack_sbuffer_init(&sbuf); msgpack_packer pk; @@ -101,7 +101,7 @@ static int handle_request(struct settings cfg, int write_fd, msgpack_object req) fprintf(stderr, "\n"); } - msgpack_sbuffer sbuf __attribute__((__cleanup__(msgpack_sbuffer_destroy))); /* buffer */ + msgpack_sbuffer sbuf __attribute__((__cleanup__(msgpack_sbuffer_destroy))) = {0}; /* buffer */ msgpack_sbuffer_init(&sbuf); /* initialize buffer */ msgpack_packer pk; /* packer */ @@ -186,7 +186,7 @@ int communicate(struct settings cfg, int read_fd, int write_fd) memcpy(msgpack_unpacker_buffer(&unp), buf, size); msgpack_unpacker_buffer_consumed(&unp, size); - msgpack_unpacked req __attribute__((__cleanup__(msgpack_unpacked_destroy))); + msgpack_unpacked req __attribute__((__cleanup__(msgpack_unpacked_destroy))) = {0}; msgpack_unpacked_init(&req); switch (msgpack_unpacker_next(&unp, &req)) { @@ -225,7 +225,7 @@ static int run_tests(struct settings cfg, int port) 1 }, sizeof(int))); - struct sockaddr_in servaddr; + struct sockaddr_in servaddr = {0}; servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htons(INADDR_ANY); servaddr.sin_port = htons(port);