remove data padding

This commit is contained in:
hippoz 2023-01-19 03:43:05 +02:00
parent 2fb13032ab
commit 7cdd84ac63
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

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