diff --git a/service/event_handler/src/key_event_value_transformation.cpp b/service/event_handler/src/key_event_value_transformation.cpp index fb84fa1c37b1bb4a762260afd178991199ea2113..36c9e85f536dbf00656714da5a5000c8520936ba 100644 --- a/service/event_handler/src/key_event_value_transformation.cpp +++ b/service/event_handler/src/key_event_value_transformation.cpp @@ -502,9 +502,14 @@ int32_t keyItemsTransKeyIntention(const std::vector &items) return KeyEvent::INTENTION_UNKNOWN; } - int64_t keyCodes = 0; + uint64_t keyCodes = 0; for (const auto &item : items) { - keyCodes = (keyCodes << 16) + item.GetKeyCode(); + if (item.GetKeyCode() < 0) { + MMI_HILOGE("keycode is invalid"); + return KeyEvent::INTENTION_UNKNOWN; + } + uint64_t keyCode = (uint64_t)item.GetKeyCode(); + keyCodes = (keyCodes << 16) + keyCode; } auto iter = MAP_KEY_INTENTION.find(keyCodes); if (iter == MAP_KEY_INTENTION.end()) { diff --git a/service/window_manager/src/input_display_bind_helper.cpp b/service/window_manager/src/input_display_bind_helper.cpp index 3c67e74e600ec647f54197bcc91019831b127a09..c95f6943c76f25f1c13369d2033e0ab8c98fb746 100644 --- a/service/window_manager/src/input_display_bind_helper.cpp +++ b/service/window_manager/src/input_display_bind_helper.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -374,13 +375,29 @@ void InputDisplayBindHelper::RemoveDisplay(int32_t id) infos_->UnbindDisplay(id); } +bool verify_file(char *const filename) +{ + if ((strlen(filename) <= PATH_MAX)) { + return true; + } else { + MMI_HILOGE("file name is empty"); + return false; + } +} + void InputDisplayBindHelper::Store() { CALL_DEBUG_ENTER; + char *realpathRes = NULL; if (infos_ == nullptr) { return; } - if (fileName_.empty()) { + realpathRes = realpath(fileName_.c_str(), NULL); + if (realpathRes == NULL) { + MMI_HILOGE("file name is empty"); + return; + } + if (!verify_file(realpathRes)) { MMI_HILOGE("file name is empty"); return; } @@ -391,6 +408,8 @@ void InputDisplayBindHelper::Store() } ofs << *infos_; ofs.close(); + free(realpathRes); + realpathRes = NULL; } int32_t InputDisplayBindHelper::GetDisplayBindInfo(DisplayBindInfos &infos) @@ -491,7 +510,13 @@ int32_t InputDisplayBindHelper::SetDisplayBind(int32_t deviceId, int32_t display void InputDisplayBindHelper::Load() { CALL_DEBUG_ENTER; - if (fileName_.empty()) { + char *realpathRes = NULL; + realpathRes = realpath(fileName_.c_str(), NULL); + if (realpathRes == NULL) { + MMI_HILOGE("file name is empty"); + return; + } + if (!verify_file(realpathRes)) { MMI_HILOGE("file name is empty"); return; } @@ -503,6 +528,8 @@ void InputDisplayBindHelper::Load() } ifs >> *configFileInfos_; ifs.close(); + free(realpathRes); + realpathRes = NULL; } std::string InputDisplayBindHelper::Dumps() const