Skip to content

Commit

Permalink
xenstore: add missing NULL check
Browse files Browse the repository at this point in the history
In case of allocation error, we should not dereference the obtained
NULL pointer.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Signed-off-by: Michael Kurth <mku@amazon.com>
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
m-k-u authored and Julien Grall committed Mar 3, 2021
1 parent e0ca7b8 commit ff3e7e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/xenstore/xenstored_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ int write_node_raw(struct connection *conn, TDB_DATA *key, struct node *node,
}

data.dptr = talloc_size(node, data.dsize);
if (!data.dptr) {
errno = ENOMEM;
return errno;
}

hdr = (void *)data.dptr;
hdr->generation = node->generation;
hdr->num_perms = node->perms.num;
Expand Down

0 comments on commit ff3e7e7

Please sign in to comment.