From: Norbert Manthey Date: Fri, 26 Feb 2021 14:41:41 +0000 (+0100) Subject: xenstore: handle do_mkdir and do_rm failure X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~841 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e0ca7b883a27919b968dc2c9d2fe2d0096342071;p=xen.git 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 Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross Release-Acked-by: Ian Jackson --- 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;