From 7cdd84ac63fb4ddf708af6b36f508b3595f1518f Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Thu, 19 Jan 2023 03:43:05 +0200 Subject: [PATCH] remove data padding --- server.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/server.c b/server.c index 6a1397f..6e150a7 100644 --- a/server.c +++ b/server.c @@ -814,16 +814,6 @@ int bus_turn(Bus *s) static const char auth_data[] = "DATA\r\n"; static const int data_buffer_len = 16384; - // We can keep a padding of null bytes for the data buffer. In the event that, for - // example, a string function is called on a char array without a proper ending null - // byte, we will reach the null bytes here at the end instead, thus preventing a - // crash and potential corruption. While this is a good "last line of defense" - // against such issues, it is much more important for these kinds of bugs to not - // exist in the first place. This mitigation will prevent, for example, ASAN from - // finding such bugs. It's recommended that you disable this padding outside - // of production so that you can find these bugs. - static const int data_buffer_padding = 0; - TRYST(poll(s->fds, s->fd_num, -1)); for (int i = 0; i < s->fd_num; i++) { @@ -864,7 +854,7 @@ int bus_turn(Bus *s) } // We add padding. See above. - char data[data_buffer_len + data_buffer_padding]; + char data[data_buffer_len]; ssize_t bytes = recv(fd, data, data_buffer_len, 0); if (bytes <= 0) { // error during recv() OR client disconnected, disconnect the client