From d81f29c2444e2767f2e52958c3aab7ec4bf71065 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 16 Nov 2017 16:46:46 +0900 Subject: [PATCH] elm: atspi: add null check and fix crash from plug_id The format of receiving plug_id may change, causing a crash. So add null check and set bus value from 0 to split. original patch : cee0b0f4a74629bf5d6f77cc0936dc87aebf44e8 Change-Id: Ic59925c438135c9fedfa9bed4e1c374f27d5a90d --- src/lib/elementary/elm_atspi_bridge.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/lib/elementary/elm_atspi_bridge.c b/src/lib/elementary/elm_atspi_bridge.c index dda0916..6110f27 100644 --- a/src/lib/elementary/elm_atspi_bridge.c +++ b/src/lib/elementary/elm_atspi_bridge.c @@ -2041,17 +2041,27 @@ _elm_atspi_bridge_plug_id_split(const char *plug_id, char **bus, char **path) Eina_Bool ret = EINA_FALSE; if (tokens == 2) { - if (bus) *bus = strdup(split[1]); - if (path) *path = strdup(split[2]); - ret = EINA_TRUE; + if (!split[0] || !split[1]) + ret = EINA_FALSE; + else + { + if (bus) *bus = strdup(split[0]); + if (path) *path = strdup(split[1]); + ret = EINA_TRUE; + } } else if (tokens == 3) { - char buf[128]; - snprintf(buf, sizeof(buf), ":%s", split[1]); - if (bus) *bus = strdup(buf); - if (path) *path = strdup(split[2]); - ret = EINA_TRUE; + if (!split[0] || !split[1] || !split[2]) + ret = EINA_FALSE; + else + { + char buf[128]; + snprintf(buf, sizeof(buf), "%s:%s",split[0], split[1]); + if (bus) *bus = strdup(buf); + if (path) *path = strdup(split[2]); + ret = EINA_TRUE; + } } free(split[0]); -- 2.7.4