From e4274e3af5097e3ca13bb101484f8d37530e9be4 Mon Sep 17 00:00:00 2001 From: "intae, jeon" Date: Wed, 18 Jan 2017 14:58:10 +0900 Subject: [PATCH] fix svace issue Change-Id: Id427f1e70c9f9c1f82884b36e4fc27662e2b1e7e Signed-off-by: intae, jeon (cherry picked from commit a5c7294fc8074a9c97961e63f3c87cad250ac19c) --- email-core/email-storage/email-storage.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/email-core/email-storage/email-storage.c b/email-core/email-storage/email-storage.c index a4d2293..0de3a0b 100755 --- a/email-core/email-storage/email-storage.c +++ b/email-core/email-storage/email-storage.c @@ -147,6 +147,7 @@ #define UID_DEFAULT 0 /* UID = root */ #define GID "priv_email" /* GID = priv_email */ #define GID_DEFAULT 10901 /* GID = priv_email */ +#define MAX_GRP_BUF_SIZE (1024 * 4) /* this define is used for query to change data (delete, insert, update) */ #define EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction_flag, error_code) \ @@ -1748,7 +1749,12 @@ INTERNAL_FUNC int emstorage_init_db(char *multi_user_name) gid_t email_gid = -1; uid_t email_uid = -1; struct group *gr; + struct group buf_group; struct passwd *pw; + struct passwd buf_passwd; + char buf_gr[MAX_GRP_BUF_SIZE]; + char buf_pw[MAX_GRP_BUF_SIZE]; + int result = 0; if (EM_SAFE_STRLEN(multi_user_name) > 0) { err = emcore_get_container_path(multi_user_name, &prefix_path); @@ -1784,20 +1790,22 @@ INTERNAL_FUNC int emstorage_init_db(char *multi_user_name) if (ret == -1) { EM_DEBUG_EXCEPTION("_xsystem failed"); err = EMAIL_ERROR_SYSTEM_FAILURE; - } - if ((gr = getgrnam(GID)) != NULL) + result = getgrnam_r(GID, &buf_group, buf_gr, sizeof(buf_gr), &gr); + if (result == 0 && NULL != gr) email_gid = gr->gr_gid; else email_gid = GID_DEFAULT; - if ((pw = getpwnam(UID)) != NULL) + result = getpwnam_r(UID, &buf_passwd, buf_pw, sizeof(buf_pw), &pw); + if (result == 0 && NULL != pw) email_uid = pw->pw_uid; else email_uid = UID_DEFAULT; + chmod(EMAIL_SERVICE_DB_FILE_PATH, 0660); chmod(EMAIL_SERVICE_DB_JOURNAL_FILE_PATH, 0660); chmod(EMAIL_SQL_PATH, 0660); -- 2.7.4