[PATCH] config-parser: Avoid null dereference when handling config-parser

Kristian Høgsberg hoegsberg at gmail.com
Sun May 26 17:08:07 PDT 2013


On Sat, May 25, 2013 at 02:31:21AM +0900, Mun, Gwan-gyeong wrote:
> This patch fixes segmentation fault when weston starts without config file.

Thanks, committed.

Kristian

> ---
> From bb953ce110dd27d1b6504c2b9aab28e771c4410b Mon Sep 17 00:00:00 2001
> From: Mun Gwan-gyeong <elongbug at gmail.com>
> Date: Sat, 25 May 2013 02:09:13 +0900
> Subject: [PATCH] config-parser: Avoid null dereference when handling
> config-parser
> 
> backtrace:
> (gdb) bt
> #0 weston_config_get_section (config=0x0, section=0x8062f31 "keyboard",
> key=0x0, value=0x0)
> at config-parser.c:265
> #1 0x080535a1 in weston_compositor_init (ec=0x905b690,
> display=0x9056490, argc=0xbf8bd2f0,
> argv=0xbf8bd384, config_fd=-1) at compositor.c:2819
> #2 0xb75d72bb in x11_compositor_create (config_fd=-1, argv=0xbf8bd384,
> argc=<optimized out>,
> use_pixman=0, no_input=0, fullscreen=0, display=0x9056490) at
> compositor-x11.c:1527
> #3 backend_init (display=0x9056490, argc=0xbf8bd2f0, argv=0xbf8bd384,
> config_fd=-1)
> at compositor-x11.c:1746
> ---
> shared/config-parser.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index 5ef6f03..9772c12 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -262,6 +262,8 @@ weston_config_get_section(struct weston_config
> *config, const char *section,
> struct weston_config_section *s;
> struct weston_config_entry *e;
> 
> + if (config == NULL)
> + return NULL;
> wl_list_for_each(s, &config->section_list, link) {
> if (strcmp(s->name, section) != 0)
> continue;
> -- 
> 1.7.9.5
> 

> From bb953ce110dd27d1b6504c2b9aab28e771c4410b Mon Sep 17 00:00:00 2001
> From: Mun Gwan-gyeong <elongbug at gmail.com>
> Date: Sat, 25 May 2013 02:09:13 +0900
> Subject: [PATCH] config-parser: Avoid null dereference when handling
>  config-parser
> 
> backtrace:
>  (gdb) bt
>  #0  weston_config_get_section (config=0x0, section=0x8062f31 "keyboard", key=0x0, value=0x0)
>      at config-parser.c:265
>  #1  0x080535a1 in weston_compositor_init (ec=0x905b690, display=0x9056490, argc=0xbf8bd2f0,
>      argv=0xbf8bd384, config_fd=-1) at compositor.c:2819
>  #2  0xb75d72bb in x11_compositor_create (config_fd=-1, argv=0xbf8bd384, argc=<optimized out>,
>      use_pixman=0, no_input=0, fullscreen=0, display=0x9056490) at compositor-x11.c:1527
>  #3  backend_init (display=0x9056490, argc=0xbf8bd2f0, argv=0xbf8bd384, config_fd=-1)
>      at compositor-x11.c:1746
> ---
>  shared/config-parser.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index 5ef6f03..9772c12 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -262,6 +262,8 @@ weston_config_get_section(struct weston_config *config, const char *section,
>  	struct weston_config_section *s;
>  	struct weston_config_entry *e;
>  
> +	if (config == NULL)
> +		return NULL;
>  	wl_list_for_each(s, &config->section_list, link) {
>  		if (strcmp(s->name, section) != 0)
>  			continue;
> -- 
> 1.7.9.5
> 

> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel



More information about the wayland-devel mailing list