diff options
author | hyunho <hhstark.kang@samsung.com> | 2020-11-06 14:09:06 +0900 |
---|---|---|
committer | hyunho <hhstark.kang@samsung.com> | 2020-11-06 14:10:09 +0900 |
commit | 2397f8f058b2dd759135246c1c63718018bfeac8 (patch) | |
tree | 95ebeed67fd05952e9292c435ad1296bfc3b6659 | |
parent | 9e05516e12b2d480ae1ac3e5484af00513087263 (diff) | |
download | notification-2397f8f058b2dd759135246c1c63718018bfeac8.tar.gz notification-2397f8f058b2dd759135246c1c63718018bfeac8.tar.bz2 notification-2397f8f058b2dd759135246c1c63718018bfeac8.zip |
Replace strerror with strerror_r
strerror_r is a thread safe function
Change-Id: Ib4578f84a1adbc1e6629b41e9e96995706b10922
Signed-off-by: hyunho <hhstark.kang@samsung.com>
-rw-r--r-- | notification-ex/shared_file.cc | 4 | ||||
-rw-r--r-- | notification/src/notification_shared_file.c | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/notification-ex/shared_file.cc b/notification-ex/shared_file.cc index 99f2c44..cdc9382 100644 --- a/notification-ex/shared_file.cc +++ b/notification-ex/shared_file.cc @@ -41,6 +41,7 @@ #define LOG_TAG "NOTIFICATION_EX" #define CHECK_LABEL "::RO" #define NOTI_PRIV_DATA_DIR "data/.notification_ex" +#define ERR_BUFFER_SIZE 1024 using namespace std; @@ -184,6 +185,7 @@ vector<char*> SharedFile::ConvertListToArray(const list<string>& data) { bool SharedFile::IsPrivatePath(string path) const { char* smack_label = nullptr; bool ret = false; + char err_buf[ERR_BUFFER_SIZE]; if (path.empty()) { LOGE("Invalid parameter"); @@ -194,7 +196,7 @@ bool SharedFile::IsPrivatePath(string path) const { if (smack_new_label_from_path(path.c_str(), XATTR_NAME_SMACK, 1, &smack_label) <= 0) { LOGE("smack_new_label_from_path failed : %d [%s][%s]", - errno, strerror(errno), path.c_str()); + errno, strerror_r(errno, err_buf, sizeof(err_buf)), path.c_str()); return false; } diff --git a/notification/src/notification_shared_file.c b/notification/src/notification_shared_file.c index abbf043..9a585f2 100644 --- a/notification/src/notification_shared_file.c +++ b/notification/src/notification_shared_file.c @@ -40,6 +40,7 @@ #define NOTI_PRIV_DATA_DIR "data/.notification" #define MAX_TIMEOUT 5000 #define MAX_RETRY_CNT 3 +#define ERR_BUFFER_SIZE 1024 #define DUMMY_PARAM #define __OOM_CHECK(value, ret_value, free_fun) \ @@ -687,13 +688,16 @@ char *notification_check_file_path_is_private(const char *pkg_id, char *dst_path = NULL; int size; uid_t uid = getuid(); + char err_buf[ERR_BUFFER_SIZE]; + char *err_str; errno = 0; size = smack_new_label_from_path(file_path, XATTR_NAME_SMACK, TRUE, &smack_label); if (size <= 0) { - ERR("Failed to get smack info : %d [%s][%s]", - errno, strerror(errno), file_path); + err_str = strerror_r(errno, err_buf, sizeof(err_buf)); + ERR("Failed to get smack info : %d [%s][%s]", errno, err_str, + file_path); return NULL; } |