diff options
author | Hyotaek Shim <hyotaek.shim@samsung.com> | 2019-07-02 10:34:31 +0900 |
---|---|---|
committer | Hyotaek Shim <hyotaek.shim@samsung.com> | 2019-07-02 10:36:10 +0900 |
commit | 7bdf4e9de4450823d004f910618561e50a160298 (patch) | |
tree | b1add36921719cfee6b92938164b5bd5aa210df5 | |
parent | 1d9d81e63346eb49105c2a7b18c9e1c279ce90da (diff) | |
download | tizen-platform-config-tizen_5.5_tv.tar.gz tizen-platform-config-tizen_5.5_tv.tar.bz2 tizen-platform-config-tizen_5.5_tv.zip |
Fix SVACE regarding index overflow in _context[]tizen_5.5.m2_releasesubmit/tizen_5.5_mobile_hotfix/20201026.185105submit/tizen_5.5/20191031.000005submit/tizen/20190702.014044accepted/tizen/unified/20190702.114911accepted/tizen/5.5/unified/mobile/hotfix/20201027.080523accepted/tizen/5.5/unified/20191031.021020tizen_5.5_tvtizen_5.5_mobile_hotfixaccepted/tizen_5.5_unified_mobile_hotfix
Change-Id: Ibdf6e4327e614ceedd9c931e703915bc2fd418e9
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
-rw-r--r-- | src/global-api.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/global-api.c b/src/global-api.c index d122b5b..4dedf59 100644 --- a/src/global-api.c +++ b/src/global-api.c @@ -38,7 +38,7 @@ #include "signup.inc" #define TZ_UID_START 5000 -#define TZ_UID_MAX 128 +#define TZ_UID_MAX 5000 #define uid2idx(x) ((x > TZ_UID_START) ? (x - TZ_UID_START) : x) static struct tzplatform_context *_context[TZ_UID_MAX] = {0}; @@ -100,11 +100,16 @@ const char* tzplatform_getenv(enum tzplatform_variable id) const char* tzplatform_uid_getenv(uid_t uid, enum tzplatform_variable id) { - int ret = init_internal_context(uid); + int ret, idx; + + ret = init_internal_context(uid); if (ret < 0) return NULL; - return _context_getenv_tzplatform_(id, tizen_platform_config_signup, _context[uid2idx(uid)]); + idx = uid2idx(uid); + assert(idx < TZ_UID_MAX); + + return _context_getenv_tzplatform_(id, tizen_platform_config_signup, _context[idx]); } const char* tzplatform_context_getenv(struct tzplatform_context *context, enum tzplatform_variable id) @@ -139,11 +144,16 @@ const char* tzplatform_mkpath(enum tzplatform_variable id, const char *path) const char* tzplatform_uid_mkpath(uid_t uid, enum tzplatform_variable id, const char *path) { - int ret = init_internal_context(uid); + int ret, idx; + + ret = init_internal_context(uid); if (ret < 0) return NULL; - return _context_mkpath_tzplatform_(id, path, tizen_platform_config_signup, _context[uid2idx(uid)]); + idx = uid2idx(uid); + assert(idx < TZ_UID_MAX); + + return _context_mkpath_tzplatform_(id, path, tizen_platform_config_signup, _context[idx]); } const char* tzplatform_context_mkpath(struct tzplatform_context *context, enum tzplatform_variable id, const char *path) @@ -158,11 +168,16 @@ const char* tzplatform_mkpath3(enum tzplatform_variable id, const char * path, c const char* tzplatform_uid_mkpath3(uid_t uid, enum tzplatform_variable id, const char *path, const char *path2) { - int ret = init_internal_context(uid); + int ret, idx; + + ret = init_internal_context(uid); if (ret < 0) return NULL; - return _context_mkpath3_tzplatform_(id, path, path2, tizen_platform_config_signup, _context[uid2idx(uid)]); + idx = uid2idx(uid); + assert(idx < TZ_UID_MAX); + + return _context_mkpath3_tzplatform_(id, path, path2, tizen_platform_config_signup, _context[idx]); } const char* tzplatform_context_mkpath3(struct tzplatform_context *context, enum tzplatform_variable id, const char *path, const char *path2) { @@ -176,11 +191,16 @@ const char* tzplatform_mkpath4(enum tzplatform_variable id, const char * path, c const char* tzplatform_uid_mkpath4(uid_t uid, enum tzplatform_variable id, const char *path, const char *path2, const char *path3) { - int ret = init_internal_context(uid); + int ret, idx; + + ret = init_internal_context(uid); if (ret < 0) return NULL; - return _context_mkpath4_tzplatform_(id, path, path2, path3, tizen_platform_config_signup, _context[uid2idx(uid)]); + idx = uid2idx(uid); + assert(idx < TZ_UID_MAX); + + return _context_mkpath4_tzplatform_(id, path, path2, path3, tizen_platform_config_signup, _context[idx]); } const char* tzplatform_context_mkpath4(struct tzplatform_context *context, enum tzplatform_variable id, const char *path, const char *path2, const char *path3) |