From 301856b13822b09294c59568946b36556062157d Mon Sep 17 00:00:00 2001 From: Ziyan Date: Sun, 11 Sep 2016 14:21:50 +0200 Subject: libsecril-shim: fix RIL_REQUEST_DIAL The Samsung RIL crashes if uusInfo is NULL... Change-Id: I68a70b2f95ba170f97e2794ab0d318e387fa1d24 --- rilsrc/libsecril-shim/secril-shim.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/rilsrc/libsecril-shim/secril-shim.c b/rilsrc/libsecril-shim/secril-shim.c index ff2e737..ad22cee 100644 --- a/rilsrc/libsecril-shim/secril-shim.c +++ b/rilsrc/libsecril-shim/secril-shim.c @@ -6,9 +6,38 @@ static const RIL_RadioFunctions *origRilFunctions; /* A copy of the ril environment passed to RIL_Init. */ static const struct RIL_Env *rilEnv; +static void onRequestDial(int request, void *data, size_t datalen, RIL_Token t) { + RIL_Dial *dial = malloc(sizeof(RIL_Dial)); + RIL_UUS_Info *uusInfo = malloc(sizeof(RIL_UUS_Info)); + + memcpy(dial, data, datalen); + + if (dial->uusInfo == NULL) { + memset(uusInfo, 0, sizeof(RIL_UUS_Info)); + uusInfo->uusType = (RIL_UUS_Type) 0; + uusInfo->uusDcs = (RIL_UUS_DCS) 0; + uusInfo->uusData = NULL; + uusInfo->uusLength = 0; + dial->uusInfo = uusInfo; + } + + origRilFunctions->onRequest(request, dial, sizeof(RIL_Dial), t); + + free(uusInfo); + free(dial); +} + static void onRequestShim(int request, void *data, size_t datalen, RIL_Token t) { switch (request) { + /* The Samsung RIL crashes if uusInfo is NULL... */ + case RIL_REQUEST_DIAL: + if (datalen == sizeof(RIL_Dial) && data != NULL) { + onRequestDial(request, data, datalen, t); + return; + } + break; + /* Necessary; RILJ may fake this for us if we reply not supported, but we can just implement it. */ case RIL_REQUEST_GET_RADIO_CAPABILITY: ; /* lol C standard */ -- cgit v1.1