Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: syntax check of 'echo $HOME' crashes in ksh emulation mode

On Tue, 6 Oct 2015 09:33:57 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Mon, 5 Oct 2015 10:45:07 -0700
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > Hrm.  But we DO set HOME in ksh emulation if the -n option is not given.
> > What is it about no_exec that changes things?
> Not importing environment variables.

Digging deeper, I think where it's not doing the assignment is...

mod_export void
assignstrvalue(Value v, char *val, int flags)
    if (unset(EXECOPT))

(i) Doesn't that leak val?  Presumably if val is non-NULL it's
permanently allocated, and I don't think we can guarantee that never
happens.  Indeed, as far as I can see in the case we're talking about it
does happen.

(ii) It's not clear how safe the above is, as this case shows.  However,
it's definitely not safe to skip the tests in assignstrvalue() either,
and if we run them it's doing too much work for syntax checking and is
likely to mess things up owing to previous non-execution.  So this is all a
bit nasty.  (Just for once.)


Messages sorted by: Reverse Date, Date, Thread, Author