>From 80881054d0d2c6a6bdf2ca51b1ee8a64b6c2be1b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 26 Aug 2014 11:35:23 +0200 Subject: [PATCH] SDAP: Fix using of uninitialized variable When group was posix and id mapping was enabled then variable gid was used uninitialized. Valgrind error: Conditional jump or move depends on uninitialised value(s) at 0x13F1A1D7: sdap_nested_group_hash_group (sdap_async_nested_groups.c:279) by 0x13F1DAA1: sdap_nested_group_send (sdap_async_nested_groups.c:718) by 0x13F1998D: sdap_get_groups_process (sdap_async_groups.c:1847) by 0x13F0F9CE: sdap_get_generic_ext_done (sdap_async.c:1467) by 0x13F0EE9F: sdap_process_result (sdap_async.c:357) by 0x54ABFBE: tevent_common_loop_timer_delay (in /usr/lib64/libtevent.so.0.9.20) by 0x54ACFC9: ??? (in /usr/lib64/libtevent.so.0.9.20) by 0x54AB6B6: ??? (in /usr/lib64/libtevent.so.0.9.20) by 0x54A7F2C: _tevent_loop_once (in /usr/lib64/libtevent.so.0.9.20) by 0x54A80CA: tevent_common_loop_wait (in /usr/lib64/libtevent.so.0.9.20) by 0x54AB656: ??? (in /usr/lib64/libtevent.so.0.9.20) by 0x5283872: server_loop (server.c:587) --- src/providers/ldap/sdap_async_nested_groups.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/providers/ldap/sdap_async_nested_groups.c b/src/providers/ldap/sdap_async_nested_groups.c index 18a811c771206b97c70961f47ca9b3ec57f6593a..b07616a93da9a5b2007a706958c4c69de4471342 100644 --- a/src/providers/ldap/sdap_async_nested_groups.c +++ b/src/providers/ldap/sdap_async_nested_groups.c @@ -244,6 +244,7 @@ sdap_nested_group_hash_group(struct sdap_nested_group_ctx *group_ctx, int32_t ad_group_type; bool posix_group = true; bool use_id_mapping; + bool can_find_gid; if (group_ctx->opts->schema_type == SDAP_SCHEMA_AD) { ret = sysdb_attrs_get_int32_t(group, SYSDB_GROUP_TYPE, &ad_group_type); @@ -272,15 +273,17 @@ sdap_nested_group_hash_group(struct sdap_nested_group_ctx *group_ctx, group_ctx->domain->name, group_ctx->domain->domain_id); - if (posix_group && !use_id_mapping) { + can_find_gid = posix_group && !use_id_mapping; + if (can_find_gid) { ret = sysdb_attrs_get_uint32_t(group, map[SDAP_AT_GROUP_GID].sys_name, &gid); } - if (!posix_group || ret == ENOENT || (ret == EOK && gid == 0)) { + if (!can_find_gid || ret == ENOENT || (ret == EOK && gid == 0)) { DEBUG(SSSDBG_TRACE_ALL, "The group's gid was %s\n", ret == ENOENT ? "missing" : "zero"); DEBUG(SSSDBG_TRACE_INTERNAL, "Marking group as non-posix and setting GID=0!\n"); + if (ret == ENOENT || !posix_group) { ret = sysdb_attrs_add_uint32(group, map[SDAP_AT_GROUP_GID].sys_name, 0); -- 2.1.0