diff options
author | MyoungJune Park <mj2004.park@samsung.com> | 2017-08-02 17:06:18 +0900 |
---|---|---|
committer | MyoungJune Park <mj2004.park@samsung.com> | 2017-08-02 17:07:41 +0900 |
commit | 08156683669499a017fb2cbfc2f48779795b8b7a (patch) | |
tree | 55cfcef403598dbc0ab3722b6d7baed589393319 | |
parent | 1dd61fa5e3bec340b63d0430db696f3130cbe8a0 (diff) | |
download | libslp-db-util-08156683669499a017fb2cbfc2f48779795b8b7a.tar.gz libslp-db-util-08156683669499a017fb2cbfc2f48779795b8b7a.tar.bz2 libslp-db-util-08156683669499a017fb2cbfc2f48779795b8b7a.zip |
replace getenv with vconf call for security issues
- it's more safe than calling getenv to deal with Security issue.
Change-Id: I05e533af9f78d7ed6860ae666dce1f6b1d9f1e3a
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | collation.c | 10 | ||||
-rwxr-xr-x | packaging/libslp-db-util.spec | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eb292f3..015a70c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ pkg_check_modules(pkgs REQUIRED dlog glib-2.0 icu-i18n + vconf ) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/collation.c b/collation.c index b950c33..cc692ca 100644 --- a/collation.c +++ b/collation.c @@ -36,6 +36,7 @@ #include "collation.h" #include "db-util-debug.h" +#include <vconf.h> #define DB_UTIL_RETV_IF(cond,ret) \ do {\ @@ -488,8 +489,15 @@ int db_util_create_collation( ret = __db_util_dl_load_icu(); DB_UTIL_RETV_IF(ret != DB_UTIL_OK, DB_UTIL_ERROR); + const char *lang = vconf_get_str(VCONFKEY_LANGSET); /* get current locale */ - icu_symbol.icu_uloc_setDefault((const char*)getenv("LANG"), &status); + if (lang) { + icu_symbol.icu_uloc_setDefault(lang, &status); + free(lang); + } else { + DB_UTIL_TRACE_WARNING("Fail to get current language vconf : %d", DB_UTIL_ERR_ENV); + return DB_UTIL_ERROR; + } locale = icu_symbol.icu_uloc_getDefault(); if(locale == NULL) { DB_UTIL_TRACE_WARNING("Fail to get current locale : %d", DB_UTIL_ERR_ENV); diff --git a/packaging/libslp-db-util.spec b/packaging/libslp-db-util.spec index 28ffe84..84ef3fe 100755 --- a/packaging/libslp-db-util.spec +++ b/packaging/libslp-db-util.spec @@ -12,6 +12,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(icu-i18n) BuildRequires: pkgconfig(sqlite3) +BuildRequires: pkgconfig(vconf) %description DB Utility. |