xenstore: send error earlier in do_mkdir
authorWei Liu <wei.liu2@citrix.com>
Wed, 20 Jul 2016 14:13:41 +0000 (15:13 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 20 Jul 2016 15:09:21 +0000 (16:09 +0100)
XenServer's coverity instance complains that a few lines below
create_node dereferences NULL if name == NULL. It however fails to
figure out that if node is NULL, errno won't be ENOENT, so do_mkdir
should have bailed before create_node.

That said, it would be good if we don't need to go through the hops.  We
can bail earlier if name is NULL.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xenstore/xenstored_core.c

index ffc0634bf7f05fdd0342d0e2f34806e1ec156337..5b2a49bd8459934797fac3593700116e3ba1d714 100644 (file)
@@ -981,6 +981,12 @@ static void do_mkdir(struct connection *conn, struct buffered_data *in)
        struct node *node;
        const char *name = onearg(in);
 
+       if (!name) {
+               errno = EINVAL;
+               send_error(conn, errno);
+               return;
+       }
+
        name = canonicalize(conn, name);
        node = get_node(conn, in, name, XS_PERM_WRITE);