Hello,
This is for external/libselinux.
Klocwork complains android.c line 734 mkdir() return value not being checked.
Attached is the fix.
Please review and thanks for the feedback.
Regards,
Alice Chu
From f2eddc68a335f759063ebc058269abe95662054e Mon Sep 17 00:00:00 2001
From: Alice Chu <alice....@sta.samsung.com>
Date: Fri, 21 Dec 2012 15:44:52 -0800
Subject: [PATCH] Fix issues found by Klocwork.
Change-Id: Ie9f9bf484a2c01df1949eab37020dc62078081f4
---
src/android.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/android.c b/src/android.c
index a74428f..ecd0ad9 100644
--- a/src/android.c
+++ b/src/android.c
@@ -731,8 +731,14 @@ int selinux_android_load_policy(void)
if (errno == ENOENT) {
/* Fall back to legacy mountpoint. */
mnt = OLDSELINUXMNT;
- mkdir(mnt, 0755);
- rc = mount(SELINUXFS, mnt, SELINUXFS, 0, NULL);
+ if (mkdir(mnt, 0755) == 0) {
+ rc = mount(SELINUXFS, mnt, SELINUXFS, 0, NULL);
+ }
+ else {
+ selinux_log(SELINUX_ERROR,"SELinux: Could not mkdir: %s\n",
+ strerror(errno));
+ return -1;
+ }
}
}
if (rc < 0) {
--
1.7.0.4