From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 23 05:00:17 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E99BA10656B2 for ; Mon, 23 Jun 2008 05:00:17 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D95238FC17 for ; Mon, 23 Jun 2008 05:00:17 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m5N50CWT057715 for ; Mon, 23 Jun 2008 05:00:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m5N50Cdq057713; Mon, 23 Jun 2008 05:00:12 GMT (envelope-from gnats) Date: Mon, 23 Jun 2008 05:00:12 GMT Message-Id: <200806230500.m5N50Cdq057713@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: samb@catalyst.net.nz Cc: Subject: Re: bin/65299: vi(1) temp path contains double / X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: samb@catalyst.net.nz List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2008 05:00:18 -0000 The following reply was made to PR bin/65299; it has been noted by GNATS. From: samb@catalyst.net.nz To: bug-followup@FreeBSD.org, mharo@freebsd.org Cc: Subject: Re: bin/65299: vi(1) temp path contains double / Date: Mon, 23 Jun 2008 16:54:33 +1200 (NZST) ------=_20080623165433_94784 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit I don't see this causing a problem myself because it appears you can add as many directory separators as you want without problem. The _PATH_TMP value is being pulled from /usr/include/paths.h which is defined as /tmp/. vi is then adding a second / onto it. The attached patch will not insert an extra / if it's not needed. If for example _PATH_TMP was defined as /tmp///, it would only drop the trailing / and would come out as /tmp//vi.XXXXXXXXXX. It could easily enough be modified so there's only a single / between _PATH_TMP and vi.XXXXXXXXXX but it seems like it could be a bit overkill for pretty much an entirely aesthetical change. Any thoughts on this? ------=_20080623165433_94784 Content-Type: text/plain; name="exf.c.patch.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="exf.c.patch.txt" Index: contrib/nvi/common/exf.c =================================================================== --- contrib/nvi/common/exf.c (revision 179865) +++ contrib/nvi/common/exf.c (working copy) @@ -189,8 +189,14 @@ if (LF_ISSET(FS_OPENERR) || oname == NULL || !exists) { if (opts_empty(sp, O_DIRECTORY, 0)) goto err; - (void)snprintf(tname, sizeof(tname), - "%s/vi.XXXXXXXXXX", O_STR(sp, O_DIRECTORY)); + + strncpy(&tname, O_STR(sp, O_DIRECTORY), sizeof(tname)); + + (void)snprintf(tname, sizeof(tname), + tname[strlen(tname)-1] == '/' + ? "%svi.XXXXXXXXXX" : "%s/vi.XXXXXXXXXX", + O_STR(sp, O_DIRECTORY)); + if ((fd = mkstemp(tname)) == -1) { msgq(sp, M_SYSERR, "237|Unable to create temporary file"); ------=_20080623165433_94784--