NetBSD Problem Report #20112

Received: (qmail 11088 invoked by uid 605); 29 Jan 2003 20:31:12 -0000
Message-Id: <200301292030.h0TKUa307186@mail.duh.org>
Date: Wed, 29 Jan 2003 15:30:36 -0500 (EST)
From: tv@pobox.com
Sender: gnats-bugs-owner@netbsd.org
Reply-To: tv@pobox.com
To: gnats-bugs@gnats.netbsd.org
Subject: MAXINTERP set far too low for modern scripts
X-Send-Pr-Version: 3.95

>Number:         20112
>Category:       kern
>Synopsis:       MAXINTERP set far too low for modern scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 29 20:32:00 +0000 2003
>Closed-Date:    Wed Apr 02 01:02:02 +0000 2003
>Last-Modified:  Sun Aug 17 13:42:03 +0000 2003
>Originator:     Todd Vierling
>Release:        NetBSD 1.6_STABLE
>Organization:
	DUH.ORG:  Pointing out the obvious since 1994.

>Environment:
na

>Description:

#define MAXINTERP       64              /* max interpreter file name length */

The above is in <sys/param.h>.  It makes many modern scripts for
commercial packages (typically for binary emulation), which want
to do things like

#!/path/to/customized/perl/interpreter -I/path/to/custom/libs -I/path/to/more/libs

bomb.  This number really needs to be kicked up to at least 100 or so.
Or, better yet, kern_subr.c could check that the *interpreter path* is
the length actually checked, and leave its arguments out of the length
check.  Even so, interpreter pathnames may still be longer than 64....

>How-To-Repeat:

grep MAXINTERP /usr/include/sys/param.h

>Fix:

Increase the number for MAXINTERP.
>Release-Note:
>Audit-Trail:

From: Todd Vierling <tv@pobox.com>
To: netbsd-bugs@netbsd.org
Cc: gnats-bugs@netbsd.org
Subject: Re: kern/20112: MAXINTERP set far too low for modern scripts
Date: Wed, 29 Jan 2003 15:50:47 -0500 (EST)

 : #!/path/to/customized/perl/interpreter -I/path/to/custom/libs -I/path/to/more/libs

 I've been requested to provide a better test case, so here it is to
 demonstrate the problem very succinctly:

 =====
 #!/usr/pkg/bin/perl -I/obnoxiously/long/path/to/some/directory/over/64/chars

 print "hello world!\n";
 =====

 With the -I..., the MAXINTERP check fails and the script is run with a
 standard shell.  Without the -I, it runs fine.

 -- 
 -- Todd Vierling <tv@pobox.com>

From: cgd@broadcom.com
To: tv@pobox.com
Cc: netbsd-bugs@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: kern/20112: MAXINTERP set far too low for modern scripts
Date: 29 Jan 2003 13:41:54 -0800

 Hmm.  I find this diff in my local source tree.  it allow interpreter
 names (incl arguments) to the the max path length.

 I recall sending it off to somebody, i don't remember who, for
 review/comment, but don't recall hearing anything back.

 Anyway, enjoy; do with it what you will.


 cgd
 --
 Index: kern/exec_conf.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/kern/exec_conf.c,v
 retrieving revision 1.77
 diff -u -p -r1.77 exec_conf.c
 --- kern/exec_conf.c	2002/11/13 15:16:27	1.77
 +++ kern/exec_conf.c	2002/11/23 05:33:33
 @@ -189,7 +189,7 @@ extern const struct emul emul_netbsd_aou
  const struct execsw execsw_builtin[] = {
  #ifdef EXEC_SCRIPT
  	/* Shell scripts */
 -	{ MAXINTERP,
 +	{ SCRIPT_HDR_SIZE,
  	  exec_script_makecmds,
  	  { NULL },
  	  NULL,
 Index: kern/exec_script.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/kern/exec_script.c,v
 retrieving revision 1.32
 diff -u -p -r1.32 exec_script.c
 --- kern/exec_script.c	2002/10/29 12:31:23	1.32
 +++ kern/exec_script.c	2002/11/23 05:33:33
 @@ -96,7 +96,7 @@ exec_script_makecmds(struct proc *p, str
  	 * (The latter requirement means that we have to check
  	 * for both spaces and tabs later on.)
  	 */
 -	hdrlinelen = min(epp->ep_hdrvalid, MAXINTERP);
 +	hdrlinelen = min(epp->ep_hdrvalid, SCRIPT_HDR_SIZE);
  	for (cp = hdrstr + EXEC_SCRIPT_MAGICLEN; cp < hdrstr + hdrlinelen;
  	    cp++) {
  		if (*cp == '\n') {
 Index: sys/exec_script.h
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/sys/exec_script.h,v
 retrieving revision 1.7
 diff -u -p -r1.7 exec_script.h
 --- sys/exec_script.h	1997/01/22 07:09:15	1.7
 +++ sys/exec_script.h	2002/11/23 05:33:33
 @@ -36,6 +36,9 @@
  #define	EXEC_SCRIPT_MAGIC	"#!"
  #define	EXEC_SCRIPT_MAGICLEN	2

 +/* Extra 2 are for possible space between #! and shell name, and newline.  */
 +#define SCRIPT_HDR_SIZE		(EXEC_SCRIPT_MAGICLEN + MAXINTERP + 2)
 +
  #ifdef _KERNEL

  /* the shell script handler's entry in the exec switch */
 Index: sys/param.h
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/sys/param.h,v
 retrieving revision 1.153
 diff -u -p -r1.153 param.h
 --- sys/param.h	2002/11/17 22:53:46	1.153
 +++ sys/param.h	2002/11/23 05:33:34
 @@ -100,7 +100,7 @@
  #include <sys/syslimits.h>

  #define	MAXCOMLEN	16		/* max command name remembered */
 -#define	MAXINTERP	64		/* max interpreter file name length */
 +#define	MAXINTERP	PATH_MAX	/* max interpreter file name length */
  /* DEPRECATED: use LOGIN_NAME_MAX instead. */
  #define	MAXLOGNAME	(LOGIN_NAME_MAX - 1) /* max login name length */
  #define	NCARGS		ARG_MAX		/* max bytes for an exec function */


From: Todd Vierling <tv@pobox.com>
To: cgd@broadcom.com
Cc: netbsd-bugs@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: kern/20112: MAXINTERP set far too low for modern scripts
Date: Wed, 29 Jan 2003 16:48:31 -0500 (EST)

 On Wed, 29 Jan 2003 cgd@broadcom.com wrote:

 : Hmm.  I find this diff in my local source tree.  it allow interpreter
 : names (incl arguments) to the the max path length.
 :
 : I recall sending it off to somebody, i don't remember who, for
 : review/comment, but don't recall hearing anything back.

 This seems rather sensible as a default ("hint hint"), actually.  Note that
 this still doesn't address the fact that MAXINTERP is a maximum limit on the
 whole line (not just the interpreter pathname), but at least it's more than
 the obnoxiously small 64, and it names the macro used in exec_script.c
 better (SCRIPT_HDR_LEN).

 -- 
 -- Todd Vierling <tv@pobox.com>

From: cgd@broadcom.com
To: "Todd Vierling" <tv@pobox.com>
Cc: netbsd-bugs@netbsd.org, gnats-bugs@netbsd.org
Subject: Re: kern/20112: MAXINTERP set far too low for modern scripts
Date: 29 Jan 2003 13:52:46 -0800

 At Wed, 29 Jan 2003 16:48:31 -0500 (EST), Todd Vierling wrote:
 > Note that
 > this still doesn't address the fact that MAXINTERP is a maximum limit on the
 > whole line (not just the interpreter pathname), but at least it's more than
 > the obnoxiously small 64, and it names the macro used in exec_script.c
 > better (SCRIPT_HDR_LEN).

 Yes, exactly.

 (The reason why i created this diff is because i actually ran up
 against the limit in the executable name, even w/o argument...  I
 don't remember the exact details but it was a script using an
 executable installed way down deep below my home dir, or something.)


 cgd


From: "Perry E. Metzger" <perry@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/20112 CVS commit: src/sys/sys
Date: Wed,  2 Apr 2003 03:58:58 +0300 (EEST)

 Module Name:	src
 Committed By:	perry
 Date:		Wed Apr  2 00:58:57 UTC 2003

 Modified Files:
 	src/sys/sys: exec_script.h param.h

 Log Message:
 grow #! line length -- patch from cgd, fixes PR kern/20112 from Todd Vierling


 To generate a diff of this commit:
 cvs rdiff -r1.7 -r1.8 src/sys/sys/exec_script.h
 cvs rdiff -r1.162 -r1.163 src/sys/sys/param.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: "Perry E. Metzger" <perry@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/20112 CVS commit: src/sys/kern
Date: Wed,  2 Apr 2003 04:00:20 +0300 (EEST)

 Module Name:	src
 Committed By:	perry
 Date:		Wed Apr  2 01:00:20 UTC 2003

 Modified Files:
 	src/sys/kern: exec_conf.c exec_script.c

 Log Message:
 grow #! line length -- patch from cgd, fixes PR kern/20112 from Todd Vierling


 To generate a diff of this commit:
 cvs rdiff -r1.79 -r1.80 src/sys/kern/exec_conf.c
 cvs rdiff -r1.32 -r1.33 src/sys/kern/exec_script.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed 
State-Changed-By: perry 
State-Changed-When: Tue Apr 1 17:01:35 PST 2003 
State-Changed-Why:  
I applied cgd's proposed patch. 

From: Todd Vierling <tv@pobox.com>
To: "Perry E. Metzger" <perry@piermont.com>
Cc:  
Subject: Re: kern/20112
Date: Mon, 28 Apr 2003 18:12:47 -0400 (EDT)

 On Tue, 1 Apr 2003, Perry E. Metzger wrote:

 : BTW, please verify that the problem is now gone for you.

 : > Synopsis: MAXINTERP set far too low for modern scripts
 : >
 : > State-Changed-From-To: open->closed

 : > I applied cgd's proposed patch.

 Looks fine to me.  I'll merge to it in when moving to the future 2.0 release
 branch.

 -- 
 -- Todd Vierling <tv@pobox.com>

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/20112 CVS commit: [netbsd-1-6] src/sys/sys
Date: Sun, 17 Aug 2003 11:19:35 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Aug 17 11:19:35 UTC 2003

 Modified Files:
 	src/sys/sys [netbsd-1-6]: param.h

 Log Message:
 Pull up revision 1.163 (requested by tv in ticket #1423):
 grow #! line length -- patch from cgd, fixes PR kern/20112 from Todd
 Vierling


 To generate a diff of this commit:
 cvs rdiff -r1.138.4.4 -r1.138.4.5 src/sys/sys/param.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/20112 CVS commit: [netbsd-1-6] src/sys/sys
Date: Sun, 17 Aug 2003 11:19:42 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Aug 17 11:19:42 UTC 2003

 Modified Files:
 	src/sys/sys [netbsd-1-6]: exec_script.h

 Log Message:
 Pull up revision 1.8 (requested by tv in ticket #1423):
 grow #! line length -- patch from cgd, fixes PR kern/20112 from Todd
 Vierling


 To generate a diff of this commit:
 cvs rdiff -r1.7 -r1.7.54.1 src/sys/sys/exec_script.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/20112 CVS commit: [netbsd-1-6] src/sys/kern
Date: Sun, 17 Aug 2003 13:40:54 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Aug 17 13:40:54 UTC 2003

 Modified Files:
 	src/sys/kern [netbsd-1-6]: exec_conf.c

 Log Message:
 Pull up revision 1.80 (requested by tv in ticket #1424):
 grow #! line length -- patch from cgd, fixes PR kern/20112 from Todd Vierling


 To generate a diff of this commit:
 cvs rdiff -r1.72 -r1.72.4.1 src/sys/kern/exec_conf.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/20112 CVS commit: [netbsd-1-6] src/sys/kern
Date: Sun, 17 Aug 2003 13:41:01 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Aug 17 13:41:00 UTC 2003

 Modified Files:
 	src/sys/kern [netbsd-1-6]: exec_script.c

 Log Message:
 Pull up revision 1.33 (requested by tv in ticket #1424):
 grow #! line length -- patch from cgd, fixes PR kern/20112 from Todd Vierling


 To generate a diff of this commit:
 cvs rdiff -r1.30 -r1.30.10.1 src/sys/kern/exec_script.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.