public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - cman: handle malloc failure (i.e., don't deref NULL)
@ 2009-06-25  9:02 Jim Meyering
  0 siblings, 0 replies; only message in thread
From: Jim Meyering @ 2009-06-25  9:02 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=8328647a87fef1c674ae1219eb7a2c9ed2ccaf7b
Commit:        8328647a87fef1c674ae1219eb7a2c9ed2ccaf7b
Parent:        a0cbf283f445712fe358318ed39fb63aa85c3d78
Author:        Jim Meyering <meyering@redhat.com>
AuthorDate:    Mon Jun 22 23:41:02 2009 +0200
Committer:     Jim Meyering <meyering@redhat.com>
CommitterDate: Thu Jun 25 11:00:12 2009 +0200

cman: handle malloc failure (i.e., don't deref NULL)

* cman/daemon/commands.c (do_cmd_get_extrainfo):
Handle malloc failure (i.e., don't deref NULL).
(do_cmd_get_all_members): Likewise.
---
 cman/daemon/commands.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 2eb8101..3607864 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -538,6 +538,8 @@ static int do_cmd_get_extrainfo(char *cmdbuf, char **retbuf, int retsize, int *r
 		       sizeof(struct sockaddr_storage) * (MAX_INTERFACES*2))) {
 
 		*retbuf = malloc(sizeof(struct cl_extra_info) + sizeof(struct sockaddr_storage) * (MAX_INTERFACES*2));
+		if (*retbuf == NULL)
+			return -ENOMEM;
 		outbuf = *retbuf + offset;
 		einfo = (struct cl_extra_info *)outbuf;
 
@@ -635,6 +637,8 @@ static int do_cmd_get_all_members(char *cmdbuf, char **retbuf, int retsize, int
 		/* If there is not enough space in the default buffer, allocate some more. */
 		if ((retsize / sizeof(struct cl_cluster_node)) < total_nodes) {
 			*retbuf = malloc(sizeof(struct cl_cluster_node) * total_nodes + offset);
+			if (!*retbuf)
+				return -ENOMEM;
 			outbuf = *retbuf + offset;
 			log_printf(LOGSYS_LEVEL_DEBUG, "memb: get_all_members: allocated new buffer (retsize=%d)\n", retsize);
 		}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-25  9:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-25  9:02 cluster: STABLE3 - cman: handle malloc failure (i.e., don't deref NULL) Jim Meyering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).