diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-08-14 13:51:19 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-08-27 09:35:54 -0400 |
commit | da8895b8db42353fed02c4fac25d5aa155d4b291 (patch) | |
tree | 78f710be626ec3848a473d0aeda7a1e476f69d6e /server/responder/common/responder_packet.c | |
parent | 3a87621a3eeb76ce6ac3b18877874141c2dc102e (diff) | |
download | sssd-da8895b8db42353fed02c4fac25d5aa155d4b291.tar.gz sssd-da8895b8db42353fed02c4fac25d5aa155d4b291.tar.bz2 sssd-da8895b8db42353fed02c4fac25d5aa155d4b291.zip |
Fix group replies when using member/memberof
Also remove legacy memberuid support
Diffstat (limited to 'server/responder/common/responder_packet.c')
-rw-r--r-- | server/responder/common/responder_packet.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/server/responder/common/responder_packet.c b/server/responder/common/responder_packet.c index 24762934..6e581a3c 100644 --- a/server/responder/common/responder_packet.c +++ b/server/responder/common/responder_packet.c @@ -119,12 +119,16 @@ int sss_packet_grow(struct sss_packet *packet, size_t size) } packet->memsize = totlen; - packet->buffer = newmem; - packet->len = &((uint32_t *)packet->buffer)[0]; - packet->cmd = &((uint32_t *)packet->buffer)[1]; - packet->status = &((uint32_t *)packet->buffer)[2]; - packet->reserved = &((uint32_t *)packet->buffer)[3]; - packet->body = (uint8_t *)&((uint32_t *)packet->buffer)[4]; + + /* re-set pointers if realloc had to move memory */ + if (newmem != packet->buffer) { + packet->buffer = newmem; + packet->len = &((uint32_t *)packet->buffer)[0]; + packet->cmd = &((uint32_t *)packet->buffer)[1]; + packet->status = &((uint32_t *)packet->buffer)[2]; + packet->reserved = &((uint32_t *)packet->buffer)[3]; + packet->body = (uint8_t *)&((uint32_t *)packet->buffer)[4]; + } } *(packet->len) += size; @@ -132,6 +136,35 @@ int sss_packet_grow(struct sss_packet *packet, size_t size) return 0; } +/* reclaim backet previously resrved space in the packet + * usually done in functione recovering from not fatal erros */ +int sss_packet_shrink(struct sss_packet *packet, size_t size) +{ + size_t newlen; + + if (size > *(packet->len)) return EINVAL; + + newlen = *(packet->len) - size; + if (newlen < SSS_NSS_HEADER_SIZE) return EINVAL; + + *(packet->len) = newlen; + return 0; +} + +int sss_packet_set_size(struct sss_packet *packet, size_t size) +{ + size_t newlen; + + newlen = SSS_NSS_HEADER_SIZE + size; + + /* make sure we do not overflow */ + if (packet->memsize < newlen) return EINVAL; + + *(packet->len) = newlen; + + return 0; +} + int sss_packet_recv(struct sss_packet *packet, int fd) { size_t rb; |