From mharo@bitsurf.net  Wed Apr  7 11:27:32 2004
Return-Path: <mharo@bitsurf.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F0AA616A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 Apr 2004 11:27:32 -0700 (PDT)
Received: from burrito.bitsurf.net (dcn235-229.dcn.davis.ca.us [168.150.235.229])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 8E3C343D2F
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 Apr 2004 11:27:32 -0700 (PDT)
	(envelope-from mharo@bitsurf.net)
Received: from burrito.bitsurf.net (localhost [127.0.0.1])
	by burrito.bitsurf.net (8.12.10/8.12.10) with ESMTP id i37IQ4eN027004
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 7 Apr 2004 11:26:04 -0700 (PDT)
	(envelope-from mharo@burrito.bitsurf.net)
Received: (from mharo@localhost)
	by burrito.bitsurf.net (8.12.10/8.12.10/Submit) id i37IQ4VM027003;
	Wed, 7 Apr 2004 11:26:04 -0700 (PDT)
	(envelope-from mharo)
Message-Id: <200404071826.i37IQ4VM027003@burrito.bitsurf.net>
Date: Wed, 7 Apr 2004 11:26:04 -0700 (PDT)
From: Michael Haro <mharo@freebsd.org>
Reply-To: Michael Haro <mharo@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: vi temp path contains double /
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         65299
>Category:       bin
>Synopsis:       vi(1) temp path contains double /
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 07 11:30:15 PDT 2004
>Closed-Date:    Mon Dec 09 18:46:16 UTC 2013
>Last-Modified:  Mon Dec 09 18:46:16 UTC 2013
>Originator:     Michael Haro
>Release:        FreeBSD 5.2.1-RELEASE-p4 i386
>Organization:
>Environment:
System: FreeBSD burrito.bitsurf.net 5.2.1-RELEASE-p4 FreeBSD 5.2.1-RELEASE-p4 #1: Sun Apr 4 18:01:49 PDT 2004 root@burrito.bitsurf.net:/usr/obj/usr/src/sys/BURRITO i386


FreeBSD 5.2.1-RELEASE-p4

/usr/bin/vi:
     $FreeBSD: src/lib/csu/i386-elf/crti.S,v 1.6 2002/05/15 04:19:49 obrien Exp $
     $FreeBSD: src/contrib/nvi/common/exf.c,v 1.5 2001/10/26 08:25:32 jkh Exp $
     $FreeBSD: src/contrib/nvi/vi/vs_line.c,v 1.5 2002/01/31 14:23:49 sheldonh Exp $
     $FreeBSD: src/contrib/nvi/vi/vs_refresh.c,v 1.3 2001/07/19 11:02:11 dd Exp $
     $FreeBSD: src/lib/csu/i386-elf/crtn.S,v 1.5 2002/05/15 04:19:49 obrien Exp $
     $FreeBSD: src/lib/csu/common/crtbrand.c,v 1.4 2003/10/17 15:43:13 peter Exp $
     $FreeBSD: src/lib/csu/i386-elf/crt1.c,v 1.12 2003/01/26 23:14:47 markm Exp $

>Description:

When typing vi, without specifying a file, it opens a temp file...

/tmp//vi.LobK7qm9HS: new file: line 1

... I'm assuming the // in the path doesn't really matter, but it might be a problem.

>How-To-Repeat:

type vi

>Fix:

	


>Release-Note:
>Audit-Trail:

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--
 
 

From: Zhihao Yuan <zhihao.yuan@rackspace.com>
To: bug-followup@FreeBSD.org, mharo@freebsd.org
Cc:  
Subject: Re: bin/65299: vi(1) temp path contains double /
Date: Mon, 9 Dec 2013 13:26:27 -0500

 The path join is fixed everywhere across the new nvi2 in -CURRENT.
 
 Please close this PR.
 
 -- 
 Zhihao Yuan <zhihao.yuan@rackspace.com>
 The best way to predict the future is to invent it.
 ___________________________________________________
 4BSD -- http://4bsd.biz/
State-Changed-From-To: open->closed 
State-Changed-By: eadler 
State-Changed-When: Mon Dec 9 18:46:15 UTC 2013 
State-Changed-Why:  
close per Zhihao Yuan 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65299 
>Unformatted:
