[PATCH v3 1/2] config: verify that the config file is not null

Bill Spitzak spitzak at gmail.com
Wed Sep 25 13:18:46 PDT 2013


Do you think anything is really going to try to open and read the file, 
and then crash because it does not exist? If this is a concern then you 
also have to worry about the config file being deleted after Wayland 
starts up.

I think returning "" or some other non-existent file (perhaps the 
default path+name for a config file) would work.

Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian at intel.com>
>
> weston_config_parse may return NULL,
> leading to an ungraceful exit via SIGSEGV if we
> try to reference the structure.
>
> Adding a check in weston_config_full_path so that
> we return the empty file /dev/null as filename
> if we started without a config file.
>
> Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
> ---
>  shared/config-parser.c | 2 +-
>  src/compositor.c       | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index e1bf212..ef5c5b9 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -385,7 +385,7 @@ weston_config_parse(const char *name)
>  const char *
>  weston_config_get_full_path(struct weston_config *config)
>  {
> -	return config->path;
> +	return config == NULL ? "/dev/null" : config->path;
>  }
>  
>  int
> 1.8.1.2
>
> _______________________________________________
> 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