From patchwork Thu Dec 1 15:58:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Meyering X-Patchwork-Id: 128714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "rcsinet15.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id A4FD4B6F76 for ; Fri, 2 Dec 2011 02:58:48 +1100 (EST) Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pB1Fwgav010347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Dec 2011 15:58:42 GMT Received: from oss.oracle.com (oss.oracle.com [141.146.12.120]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pB1FwfKD004292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Dec 2011 15:58:41 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RW91w-0006JU-7F; Thu, 01 Dec 2011 07:58:36 -0800 Received: from rcsinet13.oracle.com ([148.87.113.125]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RW91t-0006I6-9H for fedfs-utils-devel@oss.oracle.com; Thu, 01 Dec 2011 07:58:33 -0800 Received: from mx.meyering.net (mx.meyering.net [88.168.87.75]) by rcsinet13.oracle.com (Sentrion-MTA-4.2.0/Sentrion-MTA-4.2.0) with ESMTP id pB1FwV7e012736 for ; Thu, 1 Dec 2011 15:58:32 GMT Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 699FC60157; Thu, 1 Dec 2011 16:58:30 +0100 (CET) From: Jim Meyering To: fedfs-utils-devel@oss.oracle.com Date: Thu, 1 Dec 2011 16:58:19 +0100 Message-Id: <1322755106-8171-3-git-send-email-jim@meyering.net> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1322755106-8171-1-git-send-email-jim@meyering.net> References: <1322755106-8171-1-git-send-email-jim@meyering.net> Subject: [fedfs-utils] [PATCH 2/9] fedfsd: don't return freed memory through **pathname parameter, ... X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-CT-RefId: str=0001.0A090208.4ED7A433.0077:SCFSTAT3865452, ss=1, re=-4.000, fgs=0 From: Jim Meyering even though upon error it will not be used. * src/fedfsd/svc.c (fedfsd_pathwalk): On an error path, don't set *pathname at all, and certainly not to a just-freed pointer. Spotted by coverity. Signed-off-by: Jim Meyering --- src/fedfsd/svc.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fedfsd/svc.c b/src/fedfsd/svc.c index bbe1fa1..8ba6468 100644 --- a/src/fedfsd/svc.c +++ b/src/fedfsd/svc.c @@ -316,10 +316,12 @@ fedfsd_pathwalk(const FedFsPathName fpath, char **pathname) xlog(D_CALL, "%s: Zero-component pathname", __func__); strcat(result, "/"); retval = fedfsd_pathwalk_check_term(result); - if (retval != FEDFS_OK) + if (retval != FEDFS_OK) { free(result); + return retval; + } *pathname = result; - return retval; + return FEDFS_OK; } for (i = 0; i < fpath.FedFsPathName_len; i++) {