Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
sssd.5306
140619-SYSDB-sysdb_search_entry-fix-memory-leak...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 140619-SYSDB-sysdb_search_entry-fix-memory-leak.patch of Package sssd.5306
From fd2ff8fc8c87bc604768084de382420bbd6cca9a Mon Sep 17 00:00:00 2001 From: Pavel Reichl <preichl@redhat.com> Date: Thu, 19 Jun 2014 12:09:06 +0100 Subject: [PATCH] SYSDB: sysdb_search_entry fix memory leak Allocate res on tmp_ctx instead of on mem_ctx. Also use '_' prefix convention for output parameters. Reviewed-by: Stephen Gallagher <sgallagh@redhat.com> (cherry picked from commit 09579ae252c181c7884defc0612c36108f6cf509 diff -rupN sssd-1.11.5.1-original/src/db/sysdb.h sssd-1.11.5.1-patched/src/db/sysdb.h --- sssd-1.11.5.1-original/src/db/sysdb.h 2017-01-30 14:08:05.463013252 +0100 +++ sssd-1.11.5.1-patched/src/db/sysdb.h 2017-01-30 14:09:18.435839837 +0100 @@ -515,8 +515,8 @@ int sysdb_search_entry(TALLOC_CTX *mem_c int scope, const char *filter, const char **attrs, - size_t *msgs_count, - struct ldb_message ***msgs); + size_t *_msgs_count, + struct ldb_message ***_msgs); /* Search User (by uid, sid or name) */ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx, diff -rupN sssd-1.11.5.1-original/src/db/sysdb_ops.c sssd-1.11.5.1-patched/src/db/sysdb_ops.c --- sssd-1.11.5.1-original/src/db/sysdb_ops.c 2017-01-30 14:08:05.463013252 +0100 +++ sssd-1.11.5.1-patched/src/db/sysdb_ops.c 2017-01-30 14:09:18.435839837 +0100 @@ -210,27 +210,38 @@ int sysdb_search_entry(TALLOC_CTX *mem_c int scope, const char *filter, const char **attrs, - size_t *msgs_count, - struct ldb_message ***msgs) + size_t *_msgs_count, + struct ldb_message ***_msgs) { + TALLOC_CTX *tmp_ctx; struct ldb_result *res; int ret; - ret = ldb_search(sysdb->ldb, mem_ctx, &res, + tmp_ctx = talloc_new(NULL); + if (tmp_ctx == NULL) { + ret = ENOMEM; + goto done; + } + + ret = ldb_search(sysdb->ldb, tmp_ctx, &res, base_dn, scope, attrs, filter?"%s":NULL, filter); - if (ret) { - return sysdb_error_to_errno(ret); + if (ret != EOK) { + ret = sysdb_error_to_errno(ret); + goto done; } - *msgs_count = res->count; - *msgs = talloc_steal(mem_ctx, res->msgs); + *_msgs_count = res->count; + *_msgs = talloc_steal(mem_ctx, res->msgs); if (res->count == 0) { - return ENOENT; + ret = ENOENT; + goto done; } - return EOK; +done: + talloc_zfree(tmp_ctx); + return ret; } /* =Search-Entry-by-SID-string============================================ */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor