File tcsh-6.18.01-toolong.patch of Package tcsh.19069

---
 sh.lex.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

--- sh.lex.c
+++ sh.lex.c	2020-12-09 11:43:14.259459032 +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;
@@ -184,6 +185,10 @@ lex(struct wordent *hp)
 	wdp = new;
 	wdp->word = word(parsehtime);
 	parsehtime = 0;
+	if (enterhist && toolong++ > 10 * 1024) {
+	    seterror(ERR_LTOOLONG);
+	    break;
+	}
     } while (wdp->word[0] != '\n');
     cleanup_ignore(hp);
     cleanup_until(hp);
@@ -288,9 +293,14 @@ 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);
+	goto ret;
+    }
     while ((c = getC(DOALL)) == ' ' || c == '\t')
 	continue;
     if (cmap(c, _META | _ESC))
@@ -349,6 +359,10 @@ loop:
     c1 = 0;
     dolflg = DOALL;
     for (;;) {
+	if (enterhist && toolong++ > 256 * 1024) {
+	    seterror(ERR_WTOOLONG);
+	    goto ret;
+	}
 	if (c1) {
 	    if (c == c1) {
 		c1 = 0;
openSUSE Build Service is sponsored by