From nobody@FreeBSD.org  Sat Oct 26 12:42:48 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9867B37B404
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Oct 2002 12:42:48 -0700 (PDT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1D6A543E6A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Oct 2002 12:42:48 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.6/8.12.6) with ESMTP id g9QJgl7R006496
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Oct 2002 12:42:47 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.6/8.12.6/Submit) id g9QJglfM006495;
	Sat, 26 Oct 2002 12:42:47 -0700 (PDT)
Message-Id: <200210261942.g9QJglfM006495@www.freebsd.org>
Date: Sat, 26 Oct 2002 12:42:47 -0700 (PDT)
From: Kajimoto Masato <kajimoto@iijmio-mail.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: tcsh-6.12.00's "source" command ignore commands over 4kb with ja_JP.EUC locale
X-Send-Pr-Version: www-1.0

>Number:         44504
>Category:       bin
>Synopsis:       tcsh-6.12.00's "source" command ignore commands over 4kb with ja_JP.EUC locale
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    mp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 26 12:50:01 PDT 2002
>Closed-Date:    Tue Mar 08 16:33:41 GMT 2005
>Last-Modified:  Tue Mar 08 16:33:41 GMT 2005
>Originator:     Kajimoto Masato
>Release:        FreeBSD 4.7 i386
>Organization:
individual
>Environment:
FreeBSD 4.7-RELEASE i386
and maybe all versions using tcsh-6.12.00.
>Description:
This bug is the same problem discussed in the freebsd-stable ML.
     http://docs.freebsd.org/cgi/getmsg.cgi?fetch=494343+0+/usr/local/www/db/text/2002/freebsd-stable/20020901.freebsd-stable
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=108590+0+/usr/local/www/db/text/2002/freebsd-stable/20020908.freebsd-stable
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=162447+0+archive/2002/freebsd-stable/20020908.freebsd-stable

In the tcsh's prompt, "source file" command ignore
the characters over 4096 bytes if the file
has "unset" command before 4096 bytes and /usr/share/nls/$LANG/tcsh.cat file exists.
The problem also occurs in ".cshrc".
>How-To-Repeat:
% env LANG=ja_JP.EUC /bin/tcsh -f
% source file

For example, the file has "unset a" in the first line,
following any commands with over 4096 bytes.
Tcsh will ignore all characters over the boundary of 4096 bytes.
LANG must be set to the locale with tcsh.cat in /usr/share/nls/$LANG/ before starting tcsh.
>Fix:
Apply this patch to /usr/src/contrib/tcsh/sh.c

diff -c tcsh-6.12.00.ORIG/sh.c tcsh-6.12.00/sh.c
*** tcsh-6.12.00.ORIG/sh.c      Sat Jul  6 01:28:16 2002
--- tcsh-6.12.00/sh.c   Sun Oct 27 01:34:15 2002
***************
*** 1010,1016 ****
--- 1010,1026 ----
       * descriptor to hold the name of the script (setuid case) and this name
       * mustn't be lost by closing the fd too soon.
       */
+ #ifdef NLS_BUGS
+ #ifdef NLS_CATALOGS
+     (void)catclose(catd);
+ #endif /* NLS_CATALOGS */
+ #endif /* NLS_BUGS */
      closem();
+ #ifdef NLS_BUGS
+ #ifdef NLS_CATALOGS
+     nlsinit();
+ #endif /* NLS_CATALOGS */
+ #endif /* NLS_BUGS */
  
      /*
       * Consider input a tty if it really is or we are interactive. but not for


>Release-Note:
>Audit-Trail:

From: KAJIMOTO Masato <kajimoto@iijmio-mail.jp>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc: kajimoto@iijmio-mail.jp
Subject: Re: bin/44504: tcsh-6.12.00's "source" command ignore commands
 over 4kb with ja_JP.EUC locale
Date: Tue, 25 Mar 2003 01:32:00 +0900 (JST)

 Please someone commit this patch to fix tcsh-6.12.00's bug.
 
 
 diff -c src/contrib/tcsh.orig/sh.c src/contrib/tcsh/sh.c
 *** src/contrib/tcsh.orig/sh.c	Sat Jul  6 01:28:16 2002
 --- src/contrib/tcsh/sh.c	Tue Mar  4 21:10:53 2003
 ***************
 *** 1010,1016 ****
 --- 1010,1026 ----
        * descriptor to hold the name of the script (setuid case) and this name
        * mustn't be lost by closing the fd too soon.
        */
 + #ifdef NLS_BUGS
 + #ifdef NLS_CATALOGS
 +     (void)catclose(catd);
 + #endif /* NLS_CATALOGS */
 + #endif /* NLS_BUGS */
       closem();
 + #ifdef NLS_BUGS
 + #ifdef NLS_CATALOGS
 +     nlsinit();
 + #endif /* NLS_CATALOGS */
 + #endif /* NLS_BUGS */
   
       /*
        * Consider input a tty if it really is or we are interactive. but not for
 ***************
 *** 2360,2372 ****
   void
   initdesc()
   {
 - #ifdef NLS_BUGS
 - #ifdef NLS_CATALOGS
 -     (void)catclose(catd);
 - #endif /* NLS_CATALOGS */
 - #endif /* NLS_BUGS */
 - 
 - 
       didfds = 0;			/* 0, 1, 2 aren't set up */
       (void) close_on_exec(SHIN = dcopy(0, FSHIN), 1);
       (void) close_on_exec(SHOUT = dcopy(1, FSHOUT), 1);
 --- 2370,2375 ----
 ***************
 *** 2377,2387 ****
   #endif /* CLOSE_ON_EXEC */
       isdiagatty = isatty(SHDIAG);
       isoutatty = isatty(SHOUT);
 - #ifdef NLS_BUGS
 - #ifdef NLS_CATALOGS
 -     nlsinit();
 - #endif /* NLS_CATALOGS */
 - #endif /* NLS_BUGS */
   }
   
   
 --- 2380,2385 ----

From: Peter Pentchev <roam@ringlet.net>
To: KAJIMOTO Masato <kajimoto@iijmio-mail.jp>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/44504: tcsh-6.12.00's "source" command ignore commands over 4kb with ja_JP.EUC locale
Date: Mon, 24 Mar 2003 18:43:52 +0200

 On Tue, Mar 25, 2003 at 01:32:00AM +0900, KAJIMOTO Masato wrote:
 > Please someone commit this patch to fix tcsh-6.12.00's bug.
 [patch snipped]
 
 Could you get in touch with Christos Zoulas and see if this patch
 can make its way into the mainstream tcsh sources?  Then it will
 be imported into FreeBSD at the time of the next vendor import.
 
 Thanks for the patch!
 
 G'luck,
 Peter
 
 -- 
 Peter Pentchev	roam@ringlet.net    roam@sbnd.net    roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 This sentence every third, but it still comprehensible.

From: KAJIMOTO Masato <kajimoto@iijmio-mail.jp>
To: roam@ringlet.net
Cc: bug-followup@FreeBSD.org, kajimoto@iijmio-mail.jp
Subject: Re: bin/44504: tcsh-6.12.00's "source" command ignore commands
 over 4kb with ja_JP.EUC locale
Date: Tue, 25 Mar 2003 13:15:18 +0900 (JST)

 From: Peter Pentchev <roam@ringlet.net>
 Date: Mon, 24 Mar 2003 18:43:52 +0200
 
 > On Tue, Mar 25, 2003 at 01:32:00AM +0900, KAJIMOTO Masato wrote:
 > > Please someone commit this patch to fix tcsh-6.12.00's bug.
 > [patch snipped]
 > 
 > Could you get in touch with Christos Zoulas and see if this patch
 > can make its way into the mainstream tcsh sources?  Then it will
 > be imported into FreeBSD at the time of the next vendor import.
 
 He said that next tcsh release 6.12.02 will be fixed.
 
 Thank you for the advise.
 --
 kajimoto
State-Changed-From-To: open->suspended 
State-Changed-By: roam 
State-Changed-When: Mon Mar 24 23:27:38 PST 2003 
State-Changed-Why:  
Suspend this until Christos Zoulas releases tcsh-6.12.02, 
which should contain this fix.  Then, the fix will find its way 
into FreeBSD via the normal vendor import route. 

Thanks for the fix! 


Responsible-Changed-From-To: freebsd-bugs->mp 
Responsible-Changed-By: roam 
Responsible-Changed-When: Mon Mar 24 23:27:38 PST 2003 
Responsible-Changed-Why:  
Over to the tcsh de-facto maintainer in the FreeBSD source tree. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44504 
State-Changed-From-To: suspended->closed 
State-Changed-By: ume 
State-Changed-When: Tue Mar 8 16:28:54 GMT 2005 
State-Changed-Why:  
It seems that it was fixed by another way in 6.13.00. 
Though 6.13.00 was imported in 5-STABLE, there is no 
change to MFC 6.13.00 into RELENG_4.  So, I did MFC 
only the part into RELENG_4. 
Thank you for reporting it. 

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