diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/exec.c | 8 | ||||
-rw-r--r-- | Src/lex.c | 10 |
3 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 0b6c3d869..9904c1c6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-06-03 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 23511: Src/exec.c, Src/lex.c: error if here document + too large. + 2007-06-02 Peter Stephenson <p.w.stephenson@ntlworld.com> * unposted: Functions/Calendar/age, Functions/Example/zls: diff --git a/Src/exec.c b/Src/exec.c index ccba66bf8..7e4b55d43 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3111,7 +3111,13 @@ gethere(char *str, int typ) ; for (;;) { if (bptr == buf + bsiz) { - buf = realloc(buf, 2 * bsiz); + char *newbuf = realloc(buf, 2 * bsiz); + if (!newbuf) { + /* out of memory */ + zfree(buf, bsiz); + return NULL; + } + buf = newbuf; t = buf + bsiz - (bptr - t); bptr = buf + bsiz; bsiz *= 2; diff --git a/Src/lex.c b/Src/lex.c index 7748bedad..776eaf95a 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -356,6 +356,16 @@ yylex(void) ALLOWHIST cmdpop(); hwend(); + if (!name) { + zerr("here document too large"); + while (hdocs) { + next = hdocs->next; + zfree(hdocs, sizeof(struct heredocs)); + hdocs = next; + } + tok = LEXERR; + break; + } setheredoc(hdocs->pc, REDIR_HERESTR, name); zfree(hdocs, sizeof(struct heredocs)); hdocs = next; |