-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlD+qK8ACgkQrlYvE4MpobPOywCdEzt1qEt/RHJS4RONMFwHhBSB kBcAn1s+fz536IXoO3QdvNXMoFFZoxst =Wz/k -----END PGP SIGNATURE-----
>From e8d24efcd25fb5d3afb0c5aa25e33e902aca943e Mon Sep 17 00:00:00 2001 From: Eric Paris <eparis@xxxxxxxxxx> Date: Wed, 5 Dec 2012 15:35:53 -0500 Subject: [PATCH 69/84] libsemanage: fixes from coverity Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- libsemanage/src/database_llist.c | 8 +++++--- libsemanage/src/database_policydb.c | 8 +++++--- libsemanage/src/debug.c | 3 ++- libsemanage/src/semanage_store.c | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libsemanage/src/database_llist.c b/libsemanage/src/database_llist.c index 5f0c147..53583d4 100644 --- a/libsemanage/src/database_llist.c +++ b/libsemanage/src/database_llist.c @@ -369,9 +369,11 @@ int dbase_llist_list(semanage_handle_t * handle, ERR(handle, "out of memory"); err: - for (; i >= 0; i--) - dbase->rtable->free(tmp_records[i]); - free(tmp_records); + if (tmp_records) { + for (; i >= 0; i--) + dbase->rtable->free(tmp_records[i]); + free(tmp_records); + } ERR(handle, "could not allocate record array"); return STATUS_ERR; } diff --git a/libsemanage/src/database_policydb.c b/libsemanage/src/database_policydb.c index 94850b7..dbb23b2 100644 --- a/libsemanage/src/database_policydb.c +++ b/libsemanage/src/database_policydb.c @@ -462,9 +462,11 @@ static int dbase_policydb_list(semanage_handle_t * handle, ERR(handle, "out of memory"); err: - for (; list_arg.pos >= 0; list_arg.pos--) - dbase->rtable->free(tmp_records[list_arg.pos]); - free(tmp_records); + if (tmp_records) { + for (; list_arg.pos >= 0; list_arg.pos--) + dbase->rtable->free(tmp_records[list_arg.pos]); + free(tmp_records); + } ERR(handle, "could not list records"); return STATUS_ERR; } diff --git a/libsemanage/src/debug.c b/libsemanage/src/debug.c index 90d4b4e..ea51ffb 100644 --- a/libsemanage/src/debug.c +++ b/libsemanage/src/debug.c @@ -62,11 +62,12 @@ void hidden semanage_msg_default_handler(void *varg __attribute__ ((unused)), switch (semanage_msg_get_level(handle)) { case SEMANAGE_MSG_ERR: + stream = stderr; errsv = errno; + break; case SEMANAGE_MSG_WARN: stream = stderr; break; - case SEMANAGE_MSG_INFO: default: stream = stdout; break; diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c index 13c25e3..66f37ec 100644 --- a/libsemanage/src/semanage_store.c +++ b/libsemanage/src/semanage_store.c @@ -1061,7 +1061,7 @@ int semanage_split_fc(semanage_handle_t * sh) } hd = open(semanage_path(SEMANAGE_TMP, SEMANAGE_HOMEDIR_TMPL), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); - if (!hd) { + if (hd < 0) { ERR(sh, "Could not open %s for writing.", semanage_path(SEMANAGE_TMP, SEMANAGE_HOMEDIR_TMPL)); goto cleanup; -- 1.8.1