[PATCH] Fix resource leak CIDs
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Feb 3 13:50:58 UTC 2016
Hi!
Review appreciated!
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 62f6690f399945f0d73e36f1908c0b2d04ec7246 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 14 Jan 2016 21:42:04 +0100
Subject: [PATCH 1/2] libwbclient: Add "goto fail" test macros
Signed-off-by: Volker Lendecke <vl at samba.org>
---
nsswitch/libwbclient/tests/wbclient.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index 4d04ca9..e011efe 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -48,6 +48,27 @@
#define torture_assert_wbc_ok(torture_ctx,expr,cmt,cmt_arg) \
torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt,cmt_arg)
+#define torture_assert_wbc_equal_goto_fail(torture_ctx, got, expected, cmt, cmt_arg) \
+ do { wbcErr __got = got, __expected = expected; \
+ if (!WBC_ERROR_EQUAL(__got, __expected)) { \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: " cmt, wbcErrorString(__got), wbcErrorString(__expected), cmt_arg); \
+ goto fail; \
+ } \
+ } while (0)
+
+#define torture_assert_wbc_ok_goto_fail(torture_ctx,expr,cmt,cmt_arg) \
+ torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt,cmt_arg)
+
+#define torture_assert_str_equal_goto_fail(torture_ctx,got,expected,cmt)\
+ do { const char *__got = (got), *__expected = (expected); \
+ if (strcmp(__got, __expected) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
+ goto fail;; \
+ } \
+ } while(0)
+
static bool test_wbc_ping(struct torture_context *tctx)
{
torture_assert_wbc_ok(tctx, wbcPing(),
--
2.1.4
From fb89cff23789ab5e1f45969252c944d400c6396d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 14 Jan 2016 21:42:33 +0100
Subject: [PATCH 2/2] libwbclient: Fix a few resource leak CIDs
Signed-off-by: Volker Lendecke <vl at samba.org>
---
nsswitch/libwbclient/tests/wbclient.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index e011efe..0de6096 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -475,27 +475,30 @@ static bool test_wbc_lookup_rids(struct torture_context *tctx)
{
struct wbcDomainSid builtin;
uint32_t rids[2] = { 544, 545 };
- const char *domain_name, **names;
+ const char *domain_name = NULL;
+ const char **names = NULL;
enum wbcSidType *types;
- wbcErr ret;
+ wbcErr ret = false;
wbcStringToSid("S-1-5-32", &builtin);
ret = wbcLookupRids(&builtin, 2, rids, &domain_name, &names,
&types);
- torture_assert_wbc_ok(tctx, ret, "%s", "wbcLookupRids for 544 and 545 failed");
+ torture_assert_wbc_ok_goto_fail(
+ tctx, ret, "%s", "wbcLookupRids for 544 and 545 failed");
torture_assert_str_equal(
tctx, names[0], "Administrators",
"S-1-5-32-544 not mapped to 'Administrators'");
- torture_assert_str_equal(
+ torture_assert_str_equal_goto_fail(
tctx, names[1], "Users", "S-1-5-32-545 not mapped to 'Users'");
+ ret = true;
+fail:
wbcFreeMemory(discard_const_p(char ,domain_name));
wbcFreeMemory(names);
wbcFreeMemory(types);
-
- return true;
+ return ret;
}
static bool test_wbc_get_sidaliases(struct torture_context *tctx)
--
2.1.4
More information about the samba-technical
mailing list