diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-05-25 13:52:32 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-05-29 11:47:14 -0400 |
commit | bb3527e4a45a9c87fe5dbda0c86b8f51a652a996 (patch) | |
tree | 13b5c53762242f58dd361714700846f23cb0f000 | |
parent | 94b01f4271fb187b0c337d9fa43185279bc26c19 (diff) | |
download | sssd-bb3527e4a45a9c87fe5dbda0c86b8f51a652a996.tar.gz sssd-bb3527e4a45a9c87fe5dbda0c86b8f51a652a996.tar.xz sssd-bb3527e4a45a9c87fe5dbda0c86b8f51a652a996.zip |
Send 16bit protocol numbers from the sss_client
https://fedorahosted.org/sssd/ticket/1348
NSS: Restore original protocol for getservbyport
When fixing an endianness bug, we changed the protocol unnecessarily.
-rw-r--r-- | src/sss_client/nss_services.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/sss_client/nss_services.c b/src/sss_client/nss_services.c index 3f042b4a2..5f98d8dc9 100644 --- a/src/sss_client/nss_services.c +++ b/src/sss_client/nss_services.c @@ -54,8 +54,8 @@ static void sss_nss_getservent_data_clean(void) { * * GETSERVBYPORT Request: * 0-3: 16-bit port number in network byte order - * 4-7: Reserved/padding - * 8-X: Zero-terminated string (protocol) + * 4-15: Reserved/padding + * 16-X: Zero-terminated string (protocol) * Protocol may be zero-length to imply "any" * * Replies: @@ -270,6 +270,7 @@ _nss_sss_getservbyport_r(int port, const char *protocol, size_t proto_len = 0; uint8_t *repbuf; uint8_t *data; + size_t p = 0; size_t replen, len; enum nss_status nret; int ret; @@ -286,22 +287,23 @@ _nss_sss_getservbyport_r(int port, const char *protocol, } rd.len = sizeof(uint32_t)*2 + proto_len + 1; - data = malloc(sizeof(char)*rd.len); + data = malloc(sizeof(uint8_t)*rd.len); if (data == NULL) { nret = NSS_STATUS_TRYAGAIN; goto out; } - SAFEALIGN_SET_UINT32(data, port, NULL); + SAFEALIGN_SET_UINT16(data, port, &p); /* Padding */ - memset(data + sizeof(uint32_t), 0, 4); + SAFEALIGN_SET_UINT16(data + p, 0, &p); + SAFEALIGN_SET_UINT32(data + p, 0, &p); if (protocol) { - memcpy(data + sizeof(uint32_t)*2, protocol, proto_len + 1); + memcpy(data + p, protocol, proto_len + 1); } else { /* No protocol specified, pass empty string */ - data[sizeof(uint32_t)*2] = '\0'; + data[p] = '\0'; } rd.data = data; |