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 01:39:29 +0000 |
commit | 8c39655b1b6ce4e56e44dd7dc216ddeb55a18374 (patch) | |
tree | 7fef89455274f798e6f08239b13a900cba62cc04 | |
parent | ee6711475636df432765bda09bab9a7219471b4a (diff) | |
download | tizen-platform-config-accepted/tizen_4.0_unified.tar.gz tizen-platform-config-accepted/tizen_4.0_unified.tar.bz2 tizen-platform-config-accepted/tizen_4.0_unified.zip |
Fix SVACE regarding index overflow in _context[]submit/tizen_4.0/20190702.014611accepted/tizen/4.0/unified/20190702.072315tizen_4.0accepted/tizen_4.0_unified
Change-Id: Ibdf6e4327e614ceedd9c931e703915bc2fd418e9
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
(cherry picked from commit 7bdf4e9de4450823d004f910618561e50a160298)
-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) |