Skip to contentSkip to conversation

parser: Fix here-doc EOF marker bug with negative chars

PATCH New Herbert Xu 1 participant 1 message May 24, 2024

lore
Share & tools
lore

Herbert Xu

author
#0 lore raw

PATCH 1/1 parser: Fix here-doc EOF marker bug with negative chars

The here-document EOF marker parsing code incorrectly treats all negative bytes as EOF instead of just PEOF. Fix this by testing against PEOF.

Fixes 81daadfce8d5 ("[PARSER] Removed noexpand/length check on eofmark")
---
 src/parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/parser.c +1 -1
index 27611f0..09b1cb8 100644
@@ -1127,7 +1127,7 @@ more_heredoc:
 			len = out - p;
 
 			if (len) {
-				len -= c < 0;
+				len -= c <= PEOF;
 				c = p[-1];
 
 				if (len) {
Signature · 6 lines
2.39.2

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