File 58d25ea2-xenstore-add-missing-checks-for-allocation-failure.patch of Package xen.11298

References: Not strictly required but in support of bsc#1022555

Subject: xenstore: add missing checks for allocation failure
From: Juergen Gross jgross@suse.com Mon Mar 20 09:00:21 2017 +0100
Date: Wed Mar 22 11:23:14 2017 +0000:
Git: 670a34bb3e118fd729c39f667550d5d49b0f9118

Add missing allocation failure checks.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>

Index: xen-4.5.5-testing/tools/xenstore/xenstored_core.c
===================================================================
--- xen-4.5.5-testing.orig/tools/xenstore/xenstored_core.c
+++ xen-4.5.5-testing/tools/xenstore/xenstored_core.c
@@ -836,6 +836,8 @@ static struct node *construct_node(struc
 	base = basename(name);
 	baselen = strlen(base) + 1;
 	children = talloc_array(name, char, parent->childlen + baselen);
+	if (!children)
+		goto nomem;
 	memcpy(children, parent->children, parent->childlen);
 	memcpy(children + parent->childlen, base, baselen);
 	parent->children = children;
@@ -843,13 +845,19 @@ static struct node *construct_node(struc
 
 	/* Allocate node */
 	node = talloc(name, struct node);
+	if (!node)
+		goto nomem;
 	node->tdb = tdb_context(conn);
 	node->name = talloc_strdup(node, name);
+	if (!node->name)
+		goto nomem;
 
 	/* Inherit permissions, except unprivileged domains own what they create */
 	node->num_perms = parent->num_perms;
 	node->perms = talloc_memdup(node, parent->perms,
 				    node->num_perms * sizeof(node->perms[0]));
+	if (!node->perms)
+		goto nomem;
 	if (domain_is_unprivileged(conn))
 		node->perms[0].id = conn->id;
 
@@ -859,6 +867,10 @@ static struct node *construct_node(struc
 	node->parent = parent;
 	domain_entry_inc(conn, node);
 	return node;
+
+nomem:
+	errno = ENOMEM;
+	return NULL;
 }
 
 static int destroy_node(void *_node)
openSUSE Build Service is sponsored by