app-shells/dash: remove unused patches

Signed-off-by: Michael Mair-Keimberger <mm1ke@gentoo.org>
This commit is contained in:
Michael Mair-Keimberger
2026-07-27 07:00:28 +02:00
parent f005996954
commit 54e4063551
3 changed files with 0 additions and 270 deletions

View File

@@ -1,88 +0,0 @@
From cd610905162812ca7dcf246b3dc46bce5e28e7cb Mon Sep 17 00:00:00 2001
Message-ID: <cd610905162812ca7dcf246b3dc46bce5e28e7cb.1781226895.git.sam@gentoo.org>
From: Kerin Millar <kfm@plushkava.net>
Date: Sun, 31 May 2026 13:36:09 +0800
Subject: [PATCH 1/2] builtin: Fix octal escapes in dollar-single-quotes
The test suite of gentoo-functions recently uncovered a bug concerning
the handling of octal escape sequences within dollar-single-quotes.
Here is a reproducer:
$ dash -c "x=\$'\\201'; printf '%s' \"\$x\"" | od -An -tx1
88
That is, despite the input being 0x81, the output is 0x88. Indeed, any
input between 0x81..0x88 is adversely affected and some - such as 0x82 -
induce a segfault.
I noticed the following macros in src/parser.h:
#define CTL_FIRST -127 /* first 'special' character */
#define CTLESC -127 /* escape next character */
#define CTL_LAST -120 /* last 'special' character */
Reinterpreted as unsigned char, the CTL_FIRST..CTL_LAST range maps
exactly to 0x81..0x88:
$ perl -e 'printf "%x\0", $_ & 0xFF for -127..-120' | xargs -0
81 82 83 84 85 86 87 88
From this, I was able to deduce that all of these bytes must be preceded
by CTLESC in order to be taken literally. Make it so.
Link: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=947090fb7704
Signed-off-by: Kerin Millar <kfm@plushkava.net>
The escape should also be applied to \x sequences. In fact \x81
was totally broken as it produced a multi-byte character. Fix this
by merging these two code paths.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
src/bltin/printf.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/bltin/printf.c b/src/bltin/printf.c
index 106aecd..671e781 100644
--- a/src/bltin/printf.c
+++ b/src/bltin/printf.c
@@ -332,6 +332,7 @@ unsigned conv_escape(char *str0, char *out0, bool mbchar)
char *out = out0;
char *str = str0;
unsigned value;
+ int och;
int ch;
ch = *str;
@@ -359,12 +360,18 @@ unsigned conv_escape(char *str0, char *out0, bool mbchar)
}
str--;
+
+check_value:
+ if (mbchar && (signed char)value >= CTL_FIRST &&
+ (signed char)value <= CTL_LAST)
+ USTPUTC(CTLESC, out);
break;
case 'x':
ch = 2;
hex:
+ och = ch;
value = 0;
do {
int c = *++str;
@@ -391,6 +398,9 @@ hex:
if (value < 0x80)
break;
+ if (och <= 2)
+ goto check_value;
+
if (value < 0x110000) {
int mboff = (mbchar - 1) * 2;
unsigned uni = value;
--
2.54.0

View File

@@ -1,35 +0,0 @@
From 28c4d5b126e336f1632c074fa002969ff42e7a51 Mon Sep 17 00:00:00 2001
Message-ID: <28c4d5b126e336f1632c074fa002969ff42e7a51.1781226895.git.sam@gentoo.org>
In-Reply-To: <cd610905162812ca7dcf246b3dc46bce5e28e7cb.1781226895.git.sam@gentoo.org>
References: <cd610905162812ca7dcf246b3dc46bce5e28e7cb.1781226895.git.sam@gentoo.org>
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sun, 31 May 2026 13:51:02 +0800
Subject: [PATCH 2/2] builtin: Fix unaligned access in conv_escape
When writing out the unicode character in conv_escape, use memcpy
instead of direct assignment as the output buffer may not be aligned
sufficiently.
Reported-by: Nathan Mills <the.true.nathan.mills@gmail.com>
Fixes: 776424a8f915 ("parser: Add dollar single quote")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
src/bltin/printf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bltin/printf.c b/src/bltin/printf.c
index 671e781..c2c3615 100644
--- a/src/bltin/printf.c
+++ b/src/bltin/printf.c
@@ -429,7 +429,7 @@ hex:
USTPUTC(CTLMBCHAR, out);
USTPUTC(len, out);
STADJUST(mboff, out);
- *(uint32_t *)out = value;
+ memcpy(out, &value, 4);
STADJUST(len, out);
USTPUTC(len, out);
USTPUTC(CTLMBCHAR, out);
--
2.54.0

View File

@@ -1,147 +0,0 @@
From e170d9a49b3652460d6272bba9cd20afbb8140f2 Mon Sep 17 00:00:00 2001
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat, 20 Jun 2026 17:23:30 +0800
Subject: [PATCH] input: Fix overeager NUL deletion in SMALL mode
NUL characters should not be removed from input lines that are
yet to be processed because they could become the input to the
next executed utility.
Fix this by moving the NUL deletion into pgetc when history support
is off (IS_DEFINED_SMALL).
Also fold __pgetc into pgetc since the only other caller of it
is preadbuffer and that logic can also be moved up.
Finally add a missing signed char cast for the unget characters.
Reported-by: Kerin Millar <kfm@plushkava.net>
Fixes: 44ae22beedf8 ("input: Disable lleft in SMALL mode")
Fixes: 2c92409145d0 ("input: Allow MB_LEN_MAX calls to pungetc")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
src/input.c | 66 ++++++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 31 deletions(-)
diff --git a/src/input.c b/src/input.c
index 0fb2f18..e9b9d33 100644
--- a/src/input.c
+++ b/src/input.c
@@ -217,39 +217,47 @@ static void freestrings(struct strpush *sp)
}
-static int __pgetc(void)
+/*
+ * Read a character from the script, returning PEOF on end of file.
+ * Nul characters in the input are silently discarded.
+ */
+
+int __attribute__((noinline)) pgetc(void)
{
+ struct strpush *sp = parsefile->spfree;
int c;
+ if (unlikely(sp))
+ freestrings(sp);
+
+again:
if (parsefile->unget) {
long unget = -(long)(unsigned)parsefile->unget--;
- return parsefile->nextc[unget];
+ return (signed char)parsefile->nextc[unget];
}
- if (parsefile->nleft > 0) {
+nextc:
+ if (likely(parsefile->nleft > 0)) {
parsefile->nleft--;
c = (signed char)*parsefile->nextc++;
+ } else if (unlikely(parsefile->strpush)) {
+ popstring();
+ /* The freestrings call must be delayed til the next
+ * pgetc call for PEOA to work properly.
+ */
+ goto again;
} else
c = preadbuffer();
- return c;
-}
-
-
-/*
- * Read a character from the script, returning PEOF on end of file.
- * Nul characters in the input are silently discarded.
- */
-
-int __attribute__((noinline)) pgetc(void)
-{
- struct strpush *sp = parsefile->spfree;
-
- if (unlikely(sp))
- freestrings(sp);
+ /* delete nul characters */
+ if (IS_DEFINED_SMALL && unlikely(!c)) {
+ parsefile->nextc = memmove(parsefile->nextc - 1,
+ parsefile->nextc, parsefile->nleft);
+ goto nextc;
+ }
- return __pgetc();
+ return c;
}
int pgetc_eoa(void)
@@ -374,10 +382,6 @@ static int preadbuffer(void)
int more;
char *q;
- if (unlikely(parsefile->strpush)) {
- popstring();
- return __pgetc();
- }
if (parsefile->eof & 2) {
eof:
parsefile->eof = 3;
@@ -408,6 +412,12 @@ again:
}
}
+ if (IS_DEFINED_SMALL) {
+ q += more;
+ more = 0;
+ goto done;
+ }
+
/* delete nul characters */
for (;;) {
int c;
@@ -422,9 +432,6 @@ again:
q++;
- if (IS_DEFINED_SMALL)
- goto check;
-
switch (c) {
case '\n':
goto done;
@@ -439,11 +446,8 @@ again:
}
check:
- if (more <= 0) {
- if (!IS_DEFINED_SMALL)
- goto again;
- break;
- }
+ if (more <= 0)
+ goto again;
}
done:
input_set_lleft(parsefile, more);
--
2.53.0