From: Michael Kurth <m...@amazon.com>

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 <m...@amazon.com>
Signed-off-by: Norbert Manthey <nmant...@amazon.de>
Reviewed-by: Thomas Friebel <frieb...@amazon.de>
Reviewed-by: Julien Grall <jgr...@amazon.co.uk>

---
 tools/xenstore/xenstored_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -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;
-- 
2.17.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




Reply via email to