diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-03-23 16:35:49 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-03-25 16:02:27 -0400 |
commit | 80c8a4f94d54b23bce206fdd75ff2648977ce271 (patch) | |
tree | 7a03b98f665e4ebf7005c580fd9873200f023fad /src/providers/child_common.c | |
parent | f94abf5319d8f74cacae0a98d3925d18eb6839eb (diff) | |
download | sssd-80c8a4f94d54b23bce206fdd75ff2648977ce271.tar.gz sssd-80c8a4f94d54b23bce206fdd75ff2648977ce271.tar.xz sssd-80c8a4f94d54b23bce206fdd75ff2648977ce271.zip |
Allow arbitrary-length PAM messages
The PAM standard allows for messages of any length to be returned
to the client. We were discarding all messages of length greater
than 255. This patch dynamically allocates the message buffers so
we can pass the complete message.
This resolves https://fedorahosted.org/sssd/ticket/432
Diffstat (limited to 'src/providers/child_common.c')
-rw-r--r-- | src/providers/child_common.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/providers/child_common.c b/src/providers/child_common.c index 2ad0f04e3..b98025577 100644 --- a/src/providers/child_common.c +++ b/src/providers/child_common.c @@ -149,9 +149,8 @@ struct tevent_req *read_pipe_send(TALLOC_CTX *mem_ctx, if (req == NULL) return NULL; state->fd = fd; - state->buf = talloc_array(state, uint8_t, MAX_CHILD_MSG_SIZE); + state->buf = NULL; state->len = 0; - if (state->buf == NULL) goto fail; fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, read_pipe_handler, req); @@ -176,6 +175,7 @@ static void read_pipe_handler(struct tevent_context *ev, struct read_pipe_state); ssize_t size; errno_t err; + uint8_t buf[CHILD_MSG_CHUNK]; if (flags & TEVENT_FD_WRITE) { DEBUG(1, ("read_pipe_done called with TEVENT_FD_WRITE," @@ -185,8 +185,8 @@ static void read_pipe_handler(struct tevent_context *ev, } size = read(state->fd, - state->buf + state->len, - MAX_CHILD_MSG_SIZE - state->len); + buf, + CHILD_MSG_CHUNK); if (size == -1) { err = errno; if (err == EAGAIN || err == EINTR) { @@ -198,13 +198,17 @@ static void read_pipe_handler(struct tevent_context *ev, return; } else if (size > 0) { - state->len += size; - if (state->len > MAX_CHILD_MSG_SIZE) { - DEBUG(1, ("read to much, this should never happen.\n")); - tevent_req_error(req, EINVAL); + state->buf = talloc_realloc(state, state->buf, uint8_t, + state->len + size); + if(!state->buf) { + tevent_req_error(req, ENOMEM); return; } + safealign_memcpy(&state->buf[state->len], buf, + size, &state->len); + return; + } else if (size == 0) { DEBUG(6, ("EOF received, client finished\n")); tevent_req_done(req); |