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

[PATCH XENSTORE v1 08/10] xenstore: add missing NULL check



From: Michael Kurth <mku@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Norbert Manthey <nmanthey@xxxxxxxxx>
Reviewed-by: Thomas Friebel <friebelt@xxxxxxxxx>
Reviewed-by: Julien Grall <jgrall@xxxxxxxxxxxx>

---
 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






 


Rackspace

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