From: hyunho Date: Fri, 6 Nov 2020 05:09:06 +0000 (+0900) Subject: Replace strerror with strerror_r X-Git-Tag: submit/tizen/20201106.081618~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F247015%2F1;p=platform%2Fcore%2Fapi%2Fnotification.git Replace strerror with strerror_r strerror_r is a thread safe function Change-Id: Ib4578f84a1adbc1e6629b41e9e96995706b10922 Signed-off-by: hyunho --- diff --git a/notification-ex/shared_file.cc b/notification-ex/shared_file.cc index 99f2c442..cdc93828 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 SharedFile::ConvertListToArray(const list& 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 abbf0435..9a585f27 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; }