From: Marius Vlad Date: Thu, 29 Jul 2021 08:48:57 +0000 (+0300) Subject: homescreen/hs-proxy: Guard against empty appids X-Git-Tag: lamprey_12.1.17 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Ftags%2Flamprey_12.1.17;p=apps%2Fagl-service-homescreen.git homescreen/hs-proxy: Guard against empty appids Bug-AGL: SPEC-4037 Signed-off-by: Marius Vlad Change-Id: I6a9b7fd74d81cb117afcb12639862288769b7fde (cherry picked from commit 36574a78bc7baaf3dd254ed91641fd993fc90c14) --- diff --git a/src/homescreen.cpp b/src/homescreen.cpp index 8470635..49850be 100644 --- a/src/homescreen.cpp +++ b/src/homescreen.cpp @@ -162,9 +162,13 @@ static void tap_shortcut (afb_req_t request) ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value); if(ret == AFB_REQ_NOT_STARTED_APPLICATION) { std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId); - HS_AfmMainProxy afm_proxy; - afm_proxy.start(g_hs_instance, request, id); - ret = 0; + if (!id.empty()) { + HS_AfmMainProxy afm_proxy; + afm_proxy.start(g_hs_instance, request, id); + ret = 0; + } else { + ret = AFB_EVENT_BAD_REQUEST; + } } } else { @@ -314,9 +318,13 @@ static void showWindow(afb_req_t request) ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value); if(ret == AFB_REQ_NOT_STARTED_APPLICATION) { std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId); - HS_AfmMainProxy afm_proxy; - afm_proxy.start(g_hs_instance, request, id); - ret = 0; + if (!id.empty()) { + HS_AfmMainProxy afm_proxy; + afm_proxy.start(g_hs_instance, request, id); + ret = 0; + } else { + ret = AFB_EVENT_BAD_REQUEST; + } } } else { diff --git a/src/hs-proxy.cpp b/src/hs-proxy.cpp index cdbf249..ea8976c 100644 --- a/src/hs-proxy.cpp +++ b/src/hs-proxy.cpp @@ -185,7 +185,7 @@ void HS_AfmMainProxy::start(struct hs_instance *instance, afb_req_t request, con * and client context there. We pass the closure_data with the client context * and the application id to remove it. */ - if (!instance) + if (!instance || id.empty()) return; cdata = static_cast(calloc(1, sizeof(*cdata)));