From 7c95d7d9305c72484ad280def081edbfcdbc1262 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sat, 1 Jun 2013 17:52:00 +0800 Subject: [PATCH] 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bus/desktop-file.c b/bus/desktop-file.c index ae441c5..6f585a5 100644 --- a/bus/desktop-file.c +++ b/bus/desktop-file.c @@ -322,6 +322,9 @@ new_line (BusDesktopFileParser *parser) BusDesktopFileSection *section; BusDesktopFileLine *line; + if (parser == NULL || parser->current_section < 0) + return NULL; + section = &parser->desktop_file->sections[parser->current_section]; if (section->n_allocated_lines == section->n_lines) @@ -690,7 +693,7 @@ bus_desktop_file_load (DBusString *filename, parse_comment_or_blank (&parser); else { - if (!parse_key_value (&parser, error)) + if (parser.current_section == -1 || !parse_key_value (&parser, error)) { return NULL; } -- 1.7.9.5