File tcsh-6.20.00-toolong.patch of Package tcsh.19070
commit 1ef6e9d0eef9278829f863fff55755b7a5415b81
Author: Christos Zoulas <christos@zoulas.com>
Date: Fri Jan 11 10:49:54 2019 -0500
Abort history loading on long lines
---
sh.lex.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- sh.lex.c
+++ sh.lex.c 2021-04-07 06:54:58.513075977 +0000
@@ -150,6 +150,7 @@ lex(struct wordent *hp)
struct wordent *wdp;
eChar c;
int parsehtime = enterhist;
+ int toolong = 0;
histvalid = 0;
histline.len = 0;
@@ -185,6 +186,8 @@ lex(struct wordent *hp)
wdp = new;
wdp->word = word(parsehtime);
parsehtime = 0;
+ if (enterhist && toolong++ > 10 * 1024)
+ stderror(ERR_LTOOLONG);
} while (wdp->word[0] != '\n');
cleanup_ignore(hp);
cleanup_until(hp);
@@ -297,9 +300,12 @@ word(int parsehtime)
Char hbuf[12];
int h;
int dolflg;
+ int toolong = 0;
cleanup_push(&wbuf, Strbuf_cleanup);
loop:
+ if (enterhist && toolong++ > 256 * 1024)
+ seterror(ERR_WTOOLONG);
while ((c = getC(DOALL)) == ' ' || c == '\t')
continue;
if (cmap(c, _META | _ESC))
@@ -358,6 +364,8 @@ loop:
c1 = 0;
dolflg = DOALL;
for (;;) {
+ if (enterhist && toolong++ > 256 * 1024)
+ seterror(ERR_WTOOLONG);
if (c1) {
if (c == c1) {
c1 = 0;