Skip to content

Commit

Permalink
xenstore: handle do_mkdir and do_rm failure
Browse files Browse the repository at this point in the history
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@amazon.de>
Reviewed-by: Thomas Friebel <friebelt@amazon.de>
Reviewed-by: Julien Grall <jgrall@amazon.co.uk>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
  • Loading branch information
nmanthey authored and Julien Grall committed Mar 3, 2021
1 parent 4a27a67 commit e0ca7b8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/xenstore/xenstored_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e0ca7b8

Please sign in to comment.