Subject: Re: kern/20112: MAXINTERP set far too low for modern scripts
To: None <tv@pobox.com>
From: None <cgd@broadcom.com>
List: netbsd-bugs
Date: 01/29/2003 13:41:54
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 */