From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29022 invoked by alias); 25 Jun 2009 09:02:32 -0000 Received: (qmail 28970 invoked by alias); 25 Jun 2009 09:02:31 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - cman: handle malloc failure (i.e., don't deref NULL) To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: a0cbf283f445712fe358318ed39fb63aa85c3d78 X-Git-Newrev: 8328647a87fef1c674ae1219eb7a2c9ed2ccaf7b From: Jim Meyering Message-Id: <20090625090146.08B4F120382@lists.fedorahosted.org> Date: Thu, 25 Jun 2009 09:02:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00757.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=8328647a87fef1c674ae1219eb7a2c9ed2ccaf7b Commit: 8328647a87fef1c674ae1219eb7a2c9ed2ccaf7b Parent: a0cbf283f445712fe358318ed39fb63aa85c3d78 Author: Jim Meyering AuthorDate: Mon Jun 22 23:41:02 2009 +0200 Committer: Jim Meyering 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); }