[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xenstore: handle do_mkdir and do_rm failure

commit e0ca7b883a27919b968dc2c9d2fe2d0096342071
Author:     Norbert Manthey <nmanthey@xxxxxxxxx>
AuthorDate: Fri Feb 26 15:41:41 2021 +0100
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Wed Mar 3 18:17:14 2021 +0000

    xenstore: handle do_mkdir and do_rm failure
    In the out of memory case, we might return a NULL pointer when
    canonicalizing node names. This NULL pointer is not checked when
    creating a directory, or when removing a node. This change handles
    the NULL pointer for these two cases.
    This bug was discovered and resolved using Coverity Static Analysis
    Security Testing (SAST) by Synopsys, Inc.
    Signed-off-by: Norbert Manthey <nmanthey@xxxxxxxxx>
    Reviewed-by: Thomas Friebel <friebelt@xxxxxxxxx>
    Reviewed-by: Julien Grall <jgrall@xxxxxxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
    Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
 tools/xenstore/xenstored_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 3803aef081..8febd09f55 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -1160,6 +1160,8 @@ static int do_mkdir(struct connection *conn, struct 
buffered_data *in)
                /* No permissions? */
                if (errno != ENOENT)
                        return errno;
+               if (!name)
+                       return ENOMEM;
                node = create_node(conn, in, name, NULL, 0);
                if (!node)
                        return errno;
@@ -1274,6 +1276,8 @@ static int do_rm(struct connection *conn, struct 
buffered_data *in)
        if (!node) {
                /* Didn't exist already?  Fine, if parent exists. */
                if (errno == ENOENT) {
+                       if (!name)
+                               return ENOMEM;
                        parentname = get_parent(in, name);
                        if (!parentname)
                                return errno;
generated by git-patchbot for /home/xen/git/xen.git#master



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.