Zero-initialise stack-allocated objects in hstox driver.

These potentially cause uninitialised reads on some platforms or msgpack
library versions.
This commit is contained in:
iphydf 2018-01-10 13:27:45 +00:00
parent 79d8a22b48
commit 2e33ab26df
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9

View File

@ -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);