]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix exec_imgact_shell()'s handling of two error cases: (1) Previously, if
authoralc <alc@FreeBSD.org>
Tue, 21 Sep 2010 16:24:51 +0000 (16:24 +0000)
committeralc <alc@FreeBSD.org>
Tue, 21 Sep 2010 16:24:51 +0000 (16:24 +0000)
commit524cb00f17e42971cf96e8296f984f02cb0fa592
tree678f632332f49df72469a35d01eac0912c8bef7b
parentfe208ba09513af099f5dc6f4602814ccba69a10e
Fix exec_imgact_shell()'s handling of two error cases: (1) Previously, if
the first line of a script exceeded MAXSHELLCMDLEN characters, then
exec_imgact_shell() silently truncated the line and passed on the truncated
interpreter name or argument.  Now, exec_imgact_shell() will fail and return
ENOEXEC, which is the commonly used errno among Unix variants for this type
of error. (2) Previously, exec_imgact_shell()'s check on the length of the
interpreter's name was ineffective.  In other words, exec_imgact_shell()
could not possibly fail and return ENAMETOOLONG.  The reason being that the
length of the interpreter name had to exceed MAXSHELLCMDLEN characters in
order that ENAMETOOLONG be returned.  But, the search for the end of the
interpreter name stops after at most MAXSHELLCMDLEN - 2 characters are
scanned.  (In the end, this particular error is eventually discovered
outside of exec_imgact_shell() and ENAMETOOLONG is returned.  So, the real
effect of this second change is that the error is detected earlier, in
exec_imgact_shell().)

Update the definition of MAXINTERP to the actual limit on the size of
the interpreter name that has been in effect since r142453 (from
2005).

In collaboration with: kib
lib/libc/sys/execve.2
sys/kern/imgact_shell.c
sys/sys/param.h