63 lines
2.2 KiB
Diff
63 lines
2.2 KiB
Diff
|
From effe11c0b2a5e77e1b6085d695339fc449e2481f Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
||
|
Date: Tue, 12 Jan 2016 12:02:40 +0100
|
||
|
Subject: [PATCH 32/49] SUDO: sdap_sudo_set_usn() do not steal usn
|
||
|
|
||
|
This is less error prone.
|
||
|
|
||
|
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
||
|
(cherry picked from commit 3ff3bb43ae6509905bbf7fa6540c44cdbbd0f738)
|
||
|
---
|
||
|
src/providers/ldap/sdap_sudo_shared.c | 11 +++++++++--
|
||
|
src/providers/ldap/sdap_sudo_shared.h | 2 +-
|
||
|
2 files changed, 10 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/providers/ldap/sdap_sudo_shared.c b/src/providers/ldap/sdap_sudo_shared.c
|
||
|
index b31d5d27f61b73e71ab8ad0341415ee00e2295cf..0885054e4d0e886671f7057e44d0e66e3f5ccaad 100644
|
||
|
--- a/src/providers/ldap/sdap_sudo_shared.c
|
||
|
+++ b/src/providers/ldap/sdap_sudo_shared.c
|
||
|
@@ -122,10 +122,11 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
|
||
|
|
||
|
void
|
||
|
sdap_sudo_set_usn(struct sdap_server_opts *srv_opts,
|
||
|
- char *usn)
|
||
|
+ const char *usn)
|
||
|
{
|
||
|
unsigned int usn_number;
|
||
|
char *endptr = NULL;
|
||
|
+ char *newusn;
|
||
|
|
||
|
if (srv_opts == NULL) {
|
||
|
DEBUG(SSSDBG_TRACE_FUNC, "Bug: srv_opts is NULL\n");
|
||
|
@@ -138,8 +139,14 @@ sdap_sudo_set_usn(struct sdap_server_opts *srv_opts,
|
||
|
}
|
||
|
|
||
|
if (sysdb_compare_usn(usn, srv_opts->max_sudo_value) > 0) {
|
||
|
+ newusn = talloc_strdup(srv_opts, usn);
|
||
|
+ if (newusn == NULL) {
|
||
|
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc_strdup() failed\n");
|
||
|
+ return;
|
||
|
+ }
|
||
|
+
|
||
|
talloc_zfree(srv_opts->max_sudo_value);
|
||
|
- srv_opts->max_sudo_value = talloc_steal(srv_opts, usn);
|
||
|
+ srv_opts->max_sudo_value = newusn;
|
||
|
}
|
||
|
|
||
|
usn_number = strtoul(usn, &endptr, 10);
|
||
|
diff --git a/src/providers/ldap/sdap_sudo_shared.h b/src/providers/ldap/sdap_sudo_shared.h
|
||
|
index bbc6927250cf8a9b4a92eb15bad6c718c76e2f70..76858d431d0a8f2513f71321d39822da921bf9f8 100644
|
||
|
--- a/src/providers/ldap/sdap_sudo_shared.h
|
||
|
+++ b/src/providers/ldap/sdap_sudo_shared.h
|
||
|
@@ -35,6 +35,6 @@ sdap_sudo_ptask_setup_generic(struct be_ctx *be_ctx,
|
||
|
|
||
|
void
|
||
|
sdap_sudo_set_usn(struct sdap_server_opts *srv_opts,
|
||
|
- char *usn);
|
||
|
+ const char *usn);
|
||
|
|
||
|
#endif /* _SDAP_SUDO_SHARED_H_ */
|
||
|
--
|
||
|
2.5.0
|
||
|
|