summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2013-02-27 12:12:19 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-03-01 10:24:00 +0100
commitf5fb94519172463c3c97753c5dafcee6a5591162 (patch)
treee60b49d4ebb6df95a23128a01379c3abeb668e49 /src/responder
parent0aaf4a3eb0ab9a80d8a0b7b673dcc6624a29e8ad (diff)
downloadsssd-f5fb94519172463c3c97753c5dafcee6a5591162.tar.gz
sssd-f5fb94519172463c3c97753c5dafcee6a5591162.tar.xz
sssd-f5fb94519172463c3c97753c5dafcee6a5591162.zip
autofs: fix invalid header 'number of entries' in packet
https://fedorahosted.org/sssd/ticket/1739 Pointer to packet body may change while filling packet with autofs mount points. As a consequence, we sometimes wrote the number of entries into invalid body and we recieved an arbitrary number on the client side. If the number was 0, there were some skipped entries. If the number was greater than 0, everything worked correctly, because we iterate through the cached entries until we reach packet length - we don't compare to the number.
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/autofs/autofssrv_cmd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c
index 8a79cecf3..629465438 100644
--- a/src/responder/autofs/autofssrv_cmd.c
+++ b/src/responder/autofs/autofssrv_cmd.c
@@ -1085,13 +1085,13 @@ getautomntent_process(struct autofs_cmd_ctx *cmdctx,
goto done;
}
+ /* allocate memory for number of entries in the packet */
ret = sss_packet_grow(client->creq->out, sizeof(uint32_t));
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE, ("Cannot grow packet\n"));
goto done;
}
- sss_packet_get_body(client->creq->out, &body, &blen);
rp = sizeof(uint32_t); /* We'll write the number of entries here */
left = map->entry_count - cursor;
@@ -1111,6 +1111,10 @@ getautomntent_process(struct autofs_cmd_ctx *cmdctx,
nentries++;
}
+ /* packet grows in fill_autofs_entry, body pointer may change,
+ * thus we have to obtain it here */
+ sss_packet_get_body(client->creq->out, &body, &blen);
+
rp = 0;
SAFEALIGN_SET_UINT32(&body[rp], nentries, &rp);