Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

krb5_child: Increase child buffer and chunk size #7199

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/util/atomic_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ ssize_t sss_atomic_read_safe_s(int fd, void *buf, size_t buf_len, size_t *_len)
}

if (ulen > buf_len) {
return ERANGE;
if (_len != NULL) {
*_len = ulen;
}
errno = ERANGE;
return -1;
}

if (_len != NULL) {
Expand Down
18 changes: 16 additions & 2 deletions src/util/child_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static void _read_pipe_handler(struct tevent_context *ev,
struct _read_pipe_state *state;
ssize_t size;
errno_t err;
uint8_t buf[CHILD_MSG_CHUNK];
uint8_t *buf;
size_t len = 0;

state = tevent_req_data(req, struct _read_pipe_state);
Expand All @@ -521,8 +521,23 @@ static void _read_pipe_handler(struct tevent_context *ev,
return;
}

buf = talloc_array(state, uint8_t, CHILD_MSG_CHUNK);
if (buf == NULL) {
tevent_req_error(req, ENOMEM);
return;
}

if (state->safe) {
size = sss_atomic_read_safe_s(state->fd, buf, CHILD_MSG_CHUNK, &len);
if (size == -1 && errno == ERANGE) {
buf = talloc_realloc(state, buf, uint8_t, len);
if(!buf) {
tevent_req_error(req, ENOMEM);
return;
}

size = sss_atomic_read_s(state->fd, buf, len);
}
} else {
size = sss_atomic_read_s(state->fd, buf, CHILD_MSG_CHUNK);
}
Expand All @@ -532,7 +547,6 @@ static void _read_pipe_handler(struct tevent_context *ev,
"read failed [%d][%s].\n", err, strerror(err));
tevent_req_error(req, err);
return;

} else if (size > 0) {
state->buf = talloc_realloc(state, state->buf, uint8_t,
state->len + size);
Expand Down
4 changes: 2 additions & 2 deletions src/util/child_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

#include "util/util.h"

#define IN_BUF_SIZE 512
#define CHILD_MSG_CHUNK 256
#define IN_BUF_SIZE 2048
#define CHILD_MSG_CHUNK 1024

#define SIGTERM_TO_SIGKILL_TIME 2

Expand Down