Re: dash bug: double-quoted "\" breaks glob protection for next char

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/03/2018 08:55, Herbert Xu wrote:
On Thu, Mar 08, 2018 at 01:40:32AM +0100, Harald van Dijk wrote:

If the syntax stack is to be stored on the actual stack, then real recursion
could be used instead, as attached. I tried to avoid recursion for the cases
that unpatched dash already handled properly.

It does look a lot simpler than I expected.  However, this patch
is still 30% bigger than my patch :)

That's a bit unfair: that's mostly due to moved code, not to changed code.

But size-wise, your patch still wins: parser.o does become larger with my patch than with yours, largely due to my attempts to only recurse when needed.

As real recursion doesn't seem to buy us much I think I'll stick
with the syntax stack for now.

@@ -941,20 +1042,25 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
  						c != '\\' && c != '`' &&
  						c != '$' && (
  							c != '"' ||
-							eofmark != NULL
+							(eofmark != NULL && !varnest)
+						) && (
+							c != '}' ||
+							!varnest ||
+							(dqvarnest ? innerdq : dblquote)

So this seems to be the only substantial difference between your
patch and mine.  I have looked at the behaviour of other shells
and I think I will stick with my patch's behaviour for now.

The first line of this part of my patch is about something else:

  x=\"; cat <<EOF
  ${x#"\""}
  EOF

This shouldn't print anything.

In general, if there are disagreements between shells and the
standard is not specific enough, I'll pick the approach that
results in simpler code.

Fair enough.

Cheers,
Harald van Dijk

Thanks,

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux