]> xenbits.xensource.com Git - xen.git/commitdiff
tools/xenstore: simplify and rename check_event_node()
authorJuergen Gross <jgross@suse.com>
Thu, 11 Jun 2020 14:12:40 +0000 (16:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 13:36:17 +0000 (14:36 +0100)
There is no path which allows to call check_event_node() without a
event name. So don't let the result depend on the name being NULL and
add an assert() covering that case.

Rename the function to check_special_event() to better match the
semantics.

This is part of XSA-115.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Paul Durrant <paul@xen.org>
tools/xenstore/xenstored_watch.c

index 0dc5a40b99a9408d399417734eb87f74394e15d7..458062856e7e6ad20416358ffec21aab29e26727 100644 (file)
@@ -47,13 +47,11 @@ struct watch
        char *node;
 };
 
-static bool check_event_node(const char *node)
+static bool check_special_event(const char *name)
 {
-       if (!node || !strstarts(node, "@")) {
-               errno = EINVAL;
-               return false;
-       }
-       return true;
+       assert(name);
+
+       return strstarts(name, "@");
 }
 
 /* Is child a subnode of parent, or equal? */
@@ -87,7 +85,7 @@ static void add_event(struct connection *conn,
        unsigned int len;
        char *data;
 
-       if (!check_event_node(name)) {
+       if (!check_special_event(name)) {
                /* Can this conn load node, or see that it doesn't exist? */
                struct node *node = get_node(conn, ctx, name, XS_PERM_READ);
                /*