diff mbox series

input: Fix potential out-of-bounds read in popstring

Message ID ZjNpXKnES43hHImN@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series input: Fix potential out-of-bounds read in popstring | expand

Commit Message

Herbert Xu May 2, 2024, 10:22 a.m. UTC
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 mbox series

Patch

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;