]> xenbits.xensource.com Git - xen.git/commitdiff
xenstore: handle daemon creation errors
authorNorbert Manthey <nmanthey@amazon.de>
Fri, 26 Feb 2021 14:41:39 +0000 (15:41 +0100)
committerJulien Grall <jgrall@amazon.com>
Thu, 1 Apr 2021 16:12:05 +0000 (17:12 +0100)
In rare cases, the path to the daemon socket cannot be created as it is
longer than PATH_MAX. Instead of failing with a NULL pointer dereference,
terminate the application with an error message.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Thomas Friebel <friebelt@amazon.de>
Reviewed-by: Julien Grall <jgrall@amazon.co.uk>
Reviewed-by: Juergen Gross <jgross@suse.com>
tools/xenstore/xenstored_core.c

index 8033c1e0eb28eaabc5cd64be372f5b313b946456..d54a6042a9f794c2079cc8339b563ac5a9afcb7a 100644 (file)
@@ -2005,6 +2005,9 @@ static void init_sockets(void)
        struct sockaddr_un addr;
        const char *soc_str = xs_daemon_socket();
 
+       if (!soc_str)
+               barf_perror("Failed to obtain xs domain socket");
+
        /* Create sockets for them to listen to. */
        atexit(destroy_fds);
        sock = socket(PF_UNIX, SOCK_STREAM, 0);