From: Philip Withnall Date: Fri, 29 Nov 2013 08:51:11 +0000 (+0000) Subject: libecal: Refactor system timezone key file parsing code X-Git-Tag: submit/tizen/20140917.130222~236 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f851d77bcec88d4a2e664185ba760f9cfd08ee1f;p=platform%2Fupstream%2Fevolution-data-server.git libecal: Refactor system timezone key file parsing code Previously, the code could call g_strstrip(NULL) if a line started with a quotation mark but didn’t end with one, e.g.: MyKey="some-unbalanced-value The code now ignores unbalanced quotation marks, returning the odd one in the value rather than crashing (or stripping it). Found by scan-build. https://bugzilla.gnome.org/719533 --- diff --git a/calendar/libecal/e-cal-system-timezone.c b/calendar/libecal/e-cal-system-timezone.c index 8015428..78767ca 100644 --- a/calendar/libecal/e-cal-system-timezone.c +++ b/calendar/libecal/e-cal-system-timezone.c @@ -140,21 +140,13 @@ system_timezone_read_key_file (const gchar *filename, len = strlen (value); - if (value[0] == '\"') { - if (value[len - 1] == '\"') { - if (retval) - g_free (retval); - - retval = g_strndup ( - value + 1, len - 2); - } - } else { - if (retval) - g_free (retval); - - retval = g_strdup (line + strlen (key_eq)); + if (value[0] == '\"' && value[len - 1] == '\"') { + value += 1; + len -= 2; } + g_free (retval); + retval = g_strndup (value, len); g_strstrip (retval); }