From nobody@www.freebsd.org  Sun May 19 12:51:50 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id 81A4A37B409
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 19 May 2002 12:51:49 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g4JJpmhG054440
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 19 May 2002 12:51:48 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g4JJpmE9054439;
	Sun, 19 May 2002 12:51:48 -0700 (PDT)
Message-Id: <200205191951.g4JJpmE9054439@www.freebsd.org>
Date: Sun, 19 May 2002 12:51:48 -0700 (PDT)
From: Woei-Luen@www.freebsd.org, Shyu <m8535@cn.ee.ccu.edu.tw>
To: freebsd-gnats-submit@FreeBSD.org
Subject: tftpd -c patch
X-Send-Pr-Version: www-1.0

>Number:         38303
>Category:       bin
>Synopsis:       tftpd -c patch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    billf
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 19 13:00:12 PDT 2002
>Closed-Date:    Thu Jun 24 23:13:15 GMT 2004
>Last-Modified:  Thu Jun 24 23:13:15 GMT 2004
>Originator:     Woei-Luen, Shyu
>Release:        4.6-PRERELEASE
>Organization:
National Chung-Cheng University
>Environment:
FreeBSD mail.dorm.ccu.edu.tw 4.6-PRERELEASE FreeBSD 4.6-PRERELEASE #0: Sun May 12 09:35:36 CST 2002     jonce@mail.dorm.ccu.edu.tw:/usr/obj/usr/src/sys/mail  i386

>Description:
According to the tftpd's manual page, the -c flag enables this feature: "If the directory does not exist, the client connection is refused." However, it does not work! After some hacking, I think there is a bug in the tftpd's source code and I make a patch for this bug.
>How-To-Repeat:
      
>Fix:
--- tftpd.c     Sun May 19 15:19:10 2002
+++ /usr/src/libexec/tftpd/tftpd.c      Mon May 20 03:36:23 2002
@@ -256,9 +256,9 @@
                                    NI_NUMERICHOST | NI_WITHSCOPEID);
                        asprintf(&tempchroot, "%s/%s", chroot_dir, hbuf);
                        statret = stat(tempchroot, &sb);
-                       if ((sb.st_mode & S_IFDIR) &&
-                           (statret == 0 || (statret == -1 && ipchroot == 1)))
-                               chroot_dir = tempchroot;
+                        if ( ( statret == 0 && sb.st_mode & S_IFDIR ) ||
+                             ( ipchroot == 1 ) )
+                                chroot_dir = tempchroot;
                }
                /* Must get this before chroot because /etc might go away */
                if ((nobody = getpwnam(chuser)) == NULL) {

>Release-Note:
>Audit-Trail:

From: Sander Zumbrink <sander@tunix.nl>
To: freebsd-gnats-submit@FreeBSD.org
Cc: m8535@cn.ee.ccu.edu.tw, dwmalone@FreeBSD.org
Subject: Re: bin/38303: tftpd -c patch
Date: 15 Apr 2003 09:33:33 +0200

 Hello,
 
 I needed the ip-chroot option from tftpd.  When I saw it didn't
 work I've found this bug and applied the suggested fix in
 bugreport 38303.  I've tested it and it works as described in
 the manpage of tfptd.
 
 Is this going to be commited into the FreeBSD src?
 
 Regards,
 -- 
 Sander Zumbrink <sander@tunix.nl>
 TUNIX Internet Security & Training
 Wijchenseweg 111, 6538 SW Nijmegen, Netherlands
 phone: +31-(0)24-3455000 / fax: +31-(0)24-3455001
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Tue Apr 15 00:54:51 PDT 2003 
Responsible-Changed-Why:  
I'll have a look at this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38303 
State-Changed-From-To: open->patched 
State-Changed-By: billf 
State-Changed-When: Sat Apr 19 03:09:00 PDT 2003 
State-Changed-Why:  
fixed in src/libexec/tftpd/tftpd.c:r1.27, awaiting mfc. 


Responsible-Changed-From-To: dwmalone->billf 
Responsible-Changed-By: billf 
Responsible-Changed-When: Sat Apr 19 03:09:00 PDT 2003 
Responsible-Changed-Why:  
i committed the fix (and the original bug). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38303 
State-Changed-From-To: patched->closed 
State-Changed-By: billf 
State-Changed-When: Thu Jun 24 23:12:50 GMT 2004 
State-Changed-Why:  
rev 1.27 has been merged into RELENG_4: 

/home/ncvs/src/libexec/tftpd/tftpd.c,v  <--  tftpd.c 
new revision: 1.15.2.6; previous revision: 1.15.2.5 

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