From d5c7e81dac95073613c8f8b12280ed001d4ed3b1 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose@redhat.com>
Date: Thu, 29 Jan 2015 20:31:19 +0100
Subject: [PATCH 188/188] fill_id() fix LE/BE issue with wrong data type
Related to https://fedorahosted.org/sssd/ticket/1588
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
(cherry picked from commit 866ab45027c83fafb7f7f45d34d3e1e7721b77dc)
---
src/responder/nss/nsssrv_cmd.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index da24ce1730999518b2e1bc52604940ee979072e3..c03e5db846ec5b889cab5c2c37a40ef2ae229306 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -4867,18 +4867,20 @@ static errno_t fill_id(struct sss_packet *packet,
uint8_t *body;
size_t blen;
size_t pctr = 0;
- uint64_t id;
+ uint64_t tmp_id;
+ uint32_t id;
if (id_type == SSS_ID_TYPE_GID) {
- id = ldb_msg_find_attr_as_uint64(msg, SYSDB_GIDNUM, 0);
+ tmp_id = ldb_msg_find_attr_as_uint64(msg, SYSDB_GIDNUM, 0);
} else {
- id = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0);
+ tmp_id = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0);
}
- if (id == 0 || id >= UINT32_MAX) {
+ if (tmp_id == 0 || tmp_id >= UINT32_MAX) {
DEBUG(SSSDBG_CRIT_FAILURE, "Invalid POSIX ID.\n");
return EINVAL;
}
+ id = (uint32_t) tmp_id;
ret = sss_packet_grow(packet, 4 * sizeof(uint32_t));
if (ret != EOK) {
--
2.1.0