From 431b71af837e85d1f099d9d5e2d416026a88edad Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 13:25:10 +0800 Subject: [PATCH v2] Fix dbus-daemon crash due to invalid service file dbus-daemon will crash due to invalid service file which key/value starts before section. In that situation, new_line() will try to access invalid address. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60853 Signed-off-by: Chengwei Yang --- bus/desktop-file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bus/desktop-file.c b/bus/desktop-file.c index ae441c5..bfeb72e 100644 --- a/bus/desktop-file.c +++ b/bus/desktop-file.c @@ -688,6 +688,12 @@ bus_desktop_file_load (DBusString *filename, else if (is_blank_line (&parser) || _dbus_string_get_byte (&parser.data, parser.pos) == '#') parse_comment_or_blank (&parser); + else if (parser.current_section < 0) + { + dbus_set_error(error, DBUS_ERROR_FAILED, + "invalid service file: key=value before [Section]"); + return NULL; + } else { if (!parse_key_value (&parser, error)) -- 1.7.9.5