remove data padding
This commit is contained in:
parent
2fb13032ab
commit
7cdd84ac63
1 changed files with 1 additions and 11 deletions
12
server.c
12
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
|
||||
|
|
Loading…
Reference in a new issue