1 From ea8c7b3efce4c1762411e073893e948de5d552d6 Mon Sep 17 00:00:00 2001
2 From: Ross Burton <ross.burton@intel.com>
3 Date: Tue, 17 Jul 2012 16:04:12 +0100
4 Subject: [PATCH] storage: check that the string isn't empty before splitting
6 If the string was non-NULL but empty (str="\0"), the following \0 assignment
7 would write to str[-1] and thus cause memory corruption.
9 On PPC and MIPS, this was causing crashes in glibc.
11 Signed-off-by: Ross Burton <ross.burton@intel.com>
12 Upstream-Status: Submitted
15 src/storage.c | 6 +++++-
16 1 file changed, 5 insertions(+), 1 deletion(-)
18 diff --git a/src/storage.c b/src/storage.c
19 index 47bd0cb..20766a3 100644
22 @@ -212,7 +212,11 @@ gchar **connman_storage_get_services()
25 str = g_string_free(result, FALSE);
27 + if (str && str[0] != '\0') {
29 + * Remove the trailing separator so that services doesn't end up
30 + * with an empty element.
32 str[strlen(str) - 1] = '\0';
33 services = g_strsplit(str, "/", -1);