A few minor patches for sec_acl.c
Volker Lendecke
Volker.Lendecke at SerNet.DE
Fri Dec 13 09:07:20 MST 2013
Hi!
Please 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 acfb66bfaa6f805ced2991cb034f20fd78a5f650 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 6 Dec 2013 09:25:20 +0000
Subject: [PATCH 1/4] secacl: Fix whitespace
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/security/secacl.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/libcli/security/secacl.c b/libcli/security/secacl.c
index 47184ae..b97087b 100644
--- a/libcli/security/secacl.c
+++ b/libcli/security/secacl.c
@@ -1,21 +1,21 @@
-/*
+/*
* Unix SMB/Netbios implementation.
* SEC_ACL handling routines
* Copyright (C) Andrew Tridgell 1992-1998,
* Copyright (C) Jeremy R. Allison 1995-2003.
* Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
* Copyright (C) Paul Ashton 1997-1998.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
@@ -28,12 +28,12 @@
#define SEC_ACL_HEADER_SIZE (2 * sizeof(uint16_t) + sizeof(uint32_t))
/*******************************************************************
- Create a SEC_ACL structure.
+ Create a SEC_ACL structure.
********************************************************************/
-struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
- enum security_acl_revision revision,
- int num_aces, struct security_ace *ace_list)
+struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
+ enum security_acl_revision revision,
+ int num_aces, struct security_ace *ace_list)
{
struct security_acl *dst;
int i;
@@ -51,12 +51,12 @@ struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
entries in it. This is achieved by checking that num_aces is a
positive number. */
- if ((num_aces) &&
+ if ((num_aces) &&
((dst->aces = talloc_array(dst, struct security_ace, num_aces))
== NULL)) {
return NULL;
}
-
+
for (i = 0; i < num_aces; i++) {
dst->aces[i] = ace_list[i]; /* Structure copy. */
dst->size += ace_list[i].size;
@@ -66,7 +66,7 @@ struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
}
/*******************************************************************
- Duplicate a SEC_ACL structure.
+ Duplicate a SEC_ACL structure.
********************************************************************/
struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src)
--
1.7.9.5
From 6381245e25eae366015cc432a7c97ceaa672dcc0 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 6 Dec 2013 09:26:25 +0000
Subject: [PATCH 2/4] secacl: Don't use talloc_zero
We initialize all but one field anyway
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/security/secacl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libcli/security/secacl.c b/libcli/security/secacl.c
index b97087b..5778800 100644
--- a/libcli/security/secacl.c
+++ b/libcli/security/secacl.c
@@ -38,12 +38,15 @@ struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
struct security_acl *dst;
int i;
- if((dst = talloc_zero(ctx, struct security_acl)) == NULL)
+ dst = talloc(ctx, struct security_acl);
+ if (dst == NULL) {
return NULL;
+ }
dst->revision = revision;
dst->num_aces = num_aces;
dst->size = SEC_ACL_HEADER_SIZE;
+ dst->aces = NULL;
/* Now we need to return a non-NULL address for the ace list even
if the number of aces required is zero. This is because there
--
1.7.9.5
From ed765013637fb490f23027869ad255e839d57a22 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 6 Dec 2013 09:28:40 +0000
Subject: [PATCH 3/4] secacl: Fix a memleak in an error path
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/security/secacl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcli/security/secacl.c b/libcli/security/secacl.c
index 5778800..61cf521 100644
--- a/libcli/security/secacl.c
+++ b/libcli/security/secacl.c
@@ -57,6 +57,7 @@ struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
if ((num_aces) &&
((dst->aces = talloc_array(dst, struct security_ace, num_aces))
== NULL)) {
+ TALLOC_FREE(dst);
return NULL;
}
--
1.7.9.5
From 6b5549e351d63fa84d856be5b14f42bd8a7b36ec Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 6 Dec 2013 09:29:19 +0000
Subject: [PATCH 4/4] secacl: Slightly simplify make_sec_acl
This avoids a complex if-expression
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/security/secacl.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libcli/security/secacl.c b/libcli/security/secacl.c
index 61cf521..8d2ae10 100644
--- a/libcli/security/secacl.c
+++ b/libcli/security/secacl.c
@@ -54,9 +54,12 @@ struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
entries in it. This is achieved by checking that num_aces is a
positive number. */
- if ((num_aces) &&
- ((dst->aces = talloc_array(dst, struct security_ace, num_aces))
- == NULL)) {
+ if (num_aces == 0) {
+ return dst;
+ }
+
+ dst->aces = talloc_array(dst, struct security_ace, num_aces);
+ if (dst->aces == NULL) {
TALLOC_FREE(dst);
return NULL;
}
--
1.7.9.5
More information about the samba-technical
mailing list