[comp.unix.wizards] Interesting bug in csh

pete@escher.intel.com (Peter Johnson ~) (03/11/89)

I have recently come across a peculiar bug in csh and was wondering
if it posed any security problems.

If you try to use a : modifier on a environment variable, strange
things happen.  For example:

% echo $SHELL:t
/bin/csh:t
% echo ${SHELL:t}
Variable syntax.
% ls
/bin/cshls: Command not found

This bug appears in Ultrix 2.2, 3.0, SunOS 4.0, BSD 4.3, AIX, AUX.
The only system that I have used where it does not appear is UTS.
Of course UTS chokes on it as well, but in a different way.

-Pete Johnson
Peter Johnson

pete@smdvx1.intel.COM
{amdcad,decwrl,hplabs,oliveb,pur-ee,qantel}!intelca!mipos3!pete

maart@cs.vu.nl (Maarten Litmaath) (03/15/89)

pete@escher.intel.com (Peter Johnson ~) writes:
\% echo $SHELL:t
\/bin/csh:t

Correct: according to the manual `:' modifiers don't work on environment
variables.

\% echo ${SHELL:t}
\Variable syntax.

Correct too: the string "SHELL:t" doesn't have the form of an environment
variable, namely "[_a-zA-Z][_a-zA-Z0-9]*".

\% ls
\/bin/cshls: Command not found

How's that famous record by Johnny Ray again? "Crying", wasn't it?
Anyway, you get the idea.
-- 
 Those against Rushdie haven't          |Maarten Litmaath @ VU Amsterdam:
   learned anything from the Dark Ages. |maart@cs.vu.nl, mcvax!botter!maart