[PATCH] cleanup in passdb
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Nov 18 07:41:12 MST 2014
Hi!
I'd appreciate review&push!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 1057f0289b5d5584884d15407a2483c8107aaf62 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 18 Nov 2014 10:36:50 +0100
Subject: [PATCH 1/2] lib: Use talloc_pooled_object in tcopy_passwd
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/util_pw.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lib/util/util_pw.c b/lib/util/util_pw.c
index ab3808f..1e6de4f 100644
--- a/lib/util/util_pw.c
+++ b/lib/util/util_pw.c
@@ -31,7 +31,16 @@
struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
const struct passwd *from)
{
- struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
+ struct passwd *ret;
+ size_t len = 0;
+
+ len += strlen(from->pw_name)+1;
+ len += strlen(from->pw_passwd)+1;
+ len += strlen(from->pw_gecos)+1;
+ len += strlen(from->pw_dir)+1;
+ len += strlen(from->pw_shell)+1;
+
+ ret = talloc_pooled_object(mem_ctx, struct passwd, 5, len);
if (ret == NULL)
return NULL;
--
1.9.1
From 49e0fefd810a86321c83f9ab7d23ec5c1e73770c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 18 Nov 2014 10:37:15 +0100
Subject: [PATCH 2/2] lib: Add proper {} to tcopy_passwd
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/util_pw.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/util/util_pw.c b/lib/util/util_pw.c
index 1e6de4f..dae3a69 100644
--- a/lib/util/util_pw.c
+++ b/lib/util/util_pw.c
@@ -42,8 +42,9 @@ struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
ret = talloc_pooled_object(mem_ctx, struct passwd, 5, len);
- if (ret == NULL)
+ if (ret == NULL) {
return NULL;
+ }
ret->pw_name = talloc_strdup(ret, from->pw_name);
ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
--
1.9.1
More information about the samba-technical
mailing list