summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-06-10 10:23:44 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-10 12:44:20 +0200
commit65c2e0045f2decf3b565ebedae07560cb097e0e5 (patch)
tree3f2c009434e006568285940da77b05076af8379c /src/tests
parent55d1a4662d65b478b4bd398a4abfb7f102d52f0b (diff)
downloadsssd-65c2e0045f2decf3b565ebedae07560cb097e0e5.tar.gz
sssd-65c2e0045f2decf3b565ebedae07560cb097e0e5.tar.bz2
sssd-65c2e0045f2decf3b565ebedae07560cb097e0e5.zip
Fix dereference after a NULL check in tests.
https://fedorahosted.org/sssd/ticket/1972 Coverity IDs: 11870,11871 Do not call unlink with NULL pointer.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/common_dom.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/tests/common_dom.c b/src/tests/common_dom.c
index 661271d3..9edb237e 100644
--- a/src/tests/common_dom.c
+++ b/src/tests/common_dom.c
@@ -132,12 +132,19 @@ void test_dom_suite_cleanup(const char *tests_path,
errno_t ret;
char *conf_db;
char *sys_db;
+ TALLOC_CTX *tmp_ctx;
- conf_db = talloc_asprintf(NULL, "%s/%s", tests_path, confdb_path);
- sys_db = talloc_asprintf(NULL, "%s/%s", tests_path, sysdb_path);
- if (!conf_db || !sys_db) {
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_new failed\n"));
+ return;
+ }
+
+ conf_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, confdb_path);
+ if (!conf_db) {
DEBUG(SSSDBG_CRIT_FAILURE,
- ("Could not construct db paths\n"));
+ ("Could not construct conf_db path\n"));
+ goto done;
}
errno = 0;
@@ -148,6 +155,13 @@ void test_dom_suite_cleanup(const char *tests_path,
errno, strerror(errno)));
}
+ sys_db = talloc_asprintf(tmp_ctx, "%s/%s", tests_path, sysdb_path);
+ if (!sys_db) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Could not construct sys_db path\n"));
+ goto done;
+ }
+
errno = 0;
ret = unlink(sys_db);
if (ret != 0 && errno != ENOENT) {
@@ -164,6 +178,6 @@ void test_dom_suite_cleanup(const char *tests_path,
errno, strerror(errno)));
}
- talloc_free(conf_db);
- talloc_free(sys_db);
+done:
+ talloc_free(tmp_ctx);
}