Dash Archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: Fix potential out-of-bounds read in popstring
@ 2024-05-02 10:22 Herbert Xu
  0 siblings, 0 replies; only message in thread
From: Herbert Xu @ 2024-05-02 10:22 UTC (permalink / raw
  To: DASH Mailing List

For an empty alias, the check on the last character of the alias in
popstring may read a bogus byte.  Fix this by checking whether the
alias is empty or not before reading the last byte.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 src/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/input.c b/src/input.c
index fb9858f..e56ab5f 100644
--- a/src/input.c
+++ b/src/input.c
@@ -401,7 +401,7 @@ static void popstring(void)
 	struct strpush *sp = parsefile->strpush;
 
 	INTOFF;
-	if (sp->ap) {
+	if (sp->ap && parsefile->nextc > sp->string) {
 		if (parsefile->nextc[-1] == ' ' ||
 		    parsefile->nextc[-1] == '\t') {
 			checkkwd |= CHKALIAS;
-- 
2.39.2

-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-02 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-02 10:22 [PATCH] input: Fix potential out-of-bounds read in popstring Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).