From patchwork Tue Dec 13 22:51:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 131202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "acsinet15.oracle.com", Issuer "Oracle SSL CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 012A51007D3 for ; Wed, 14 Dec 2011 09:51:30 +1100 (EST) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pBDMpN2G006491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 13 Dec 2011 22:51:23 GMT Received: from oss.oracle.com (oss.oracle.com [141.146.12.120]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pBDMpM7a011210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Dec 2011 22:51:22 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RabBt-0005zg-JH; Tue, 13 Dec 2011 14:51:17 -0800 Received: from acsinet13.oracle.com ([141.146.126.235]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RabBs-0005zZ-8t for fedfs-utils-devel@oss.oracle.com; Tue, 13 Dec 2011 14:51:16 -0800 Received: from mail-vx0-f171.google.com (mail-vx0-f171.google.com [209.85.220.171]) by acsinet13.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pBDMov1D021828 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 13 Dec 2011 22:51:15 GMT Received: by mail-vx0-f171.google.com with SMTP id fo1so205521vcb.2 for ; Tue, 13 Dec 2011 14:51:15 -0800 (PST) Received: by 10.220.147.197 with SMTP id m5mr3228233vcv.48.1323816675731; Tue, 13 Dec 2011 14:51:15 -0800 (PST) Received: from degas.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id jo9sm537437vdb.7.2011.12.13.14.51.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 14:51:15 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Tue, 13 Dec 2011 17:51:13 -0500 Message-ID: <20111213225113.15402.70544.stgit@degas.1015granger.net> In-Reply-To: <20111213224842.15402.340.stgit@degas.1015granger.net> References: <20111213224842.15402.340.stgit@degas.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=ISPs ip=209.85.220.171 ct-class=G1 ct-vol1=0 ct-vol2=0 ct-vol3=0 ct-risk=0 ct-spam1=0 ct-spam2=0 ct-bulk=0 rcpts=1 size=920 Subject: [fedfs-utils] [PATCH 02/12] mount: avoid two-byte heap write overrun 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: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-CT-RefId: str=0001.0A090204.4EE7D6ED.0047:SCFSTAT1119972, ss=1, re=-4.000, fgs=0 X-Auth-Type: Internal IP From: Jim Meyering * src/mount/main.c (try_mount): Correct off-by-two under-allocation. Rather than allocating space for strlen(S)+1, it allocates space for strlen(S+1), which is shorter by two. Spotted by coverity. Introduced by commit bfe6aa7f: "mount.fedfs: Overhaul mount.fedfs CLI," (April 1, 2011). Signed-off-by: Jim Meyering --- src/mount/main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mount/main.c b/src/mount/main.c index f76f355..b49d152 100644 --- a/src/mount/main.c +++ b/src/mount/main.c @@ -384,7 +384,7 @@ try_mount(const char *source, const char *target, const char *text_options) } else { char *tmp; - tmp = malloc(strlen(remaining + 1)); + tmp = malloc(strlen(remaining) + 1); if (tmp == NULL) { fprintf(stderr, _("%s: No memory\n"), progname); remaining = NULL;