ash: input: Allow two consecutive calls to pungetc
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 29 Sep 2016 00:11:19 +0000 (02:11 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 29 Sep 2016 00:11:19 +0000 (02:11 +0200)
commit3b4d04b77eb5cfdb8ac6a799a3f3ccf1e455d0e7
treef7486abff328ee79831a4c4ee6cc006a11006dc8
parent78c9c736ab13caec3f6c1032e39200fed5580f50
ash: input: Allow two consecutive calls to pungetc

Upstream commit:

    input: Allow two consecutive calls to pungetc

    The commit ef91d3d6a4c39421fd3a391e02cd82f9f3aee4a8 ([PARSER]
    Handle backslash newlines properly after dollar sign) created
    cases where we make two consecutive calls to pungetc.  As we
    don't explicitly support that there are corner cases where you
    end up with garbage input leading to undefined behaviour.

    This patch adds explicit support for two consecutive calls to
    pungetc.

Reported-by: Jilles Tjoelker <jilles@stack.nl>
Reported-by: Juergen Daubert <jue@jue.li>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
In bbox case, bashism >& may need two pungetc() too.

function                                             old     new   delta
pgetc                                                514     555     +41
pushstring                                           114     144     +30
basepf                                                52      76     +24
popstring                                            134     151     +17
parse_command                                       1584    1585      +1
pungetc                                               12       9      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 113/-3)            Total: 110 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c