bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk 3.1.4: don't read past EOF


From: Aharon Robbins
Subject: Re: gawk 3.1.4: don't read past EOF
Date: Mon, 20 Sep 2004 13:00:37 +0300

Applied.  Much thanks.

Arnold

> To: address@hidden
> Subject: gawk 3.1.4: don't read past EOF
> From: Andreas Schwab <address@hidden>
> Date: Sun, 19 Sep 2004 23:55:47 +0200
>
> When an awk script that is big enough to fill more than a buffer's worth
> does not end with a newline then nextc reads past EOF.
>
> Andreas.
>
> 2004-09-19  Andreas Schwab  <address@hidden>
>
>       * awkgram.y (nextc): Check for end of lexer buffer before
>       advancing ring buffer index.
>
> --- gawk-3.1.4/awkgram.y.~1~  2004-07-26 16:11:12.000000000 +0200
> +++ gawk-3.1.4/awkgram.y      2004-09-19 21:39:57.203777936 +0200
> @@ -1433,6 +1433,11 @@ static int
>  nextc(void)
>  {
>       if (gawk_mb_cur_max > 1)        {
> +             if (!lexptr || lexptr >= lexend)
> +                     if (!get_src_buf()) {
> +                             return EOF;
> +                     }
> +
>               /* Update the buffer index.  */
>               cur_ring_idx = (cur_ring_idx == RING_BUFFER_SIZE - 1)? 0 :
>                       cur_ring_idx + 1;
> @@ -1444,11 +1449,6 @@ nextc(void)
>                       mbstate_t tmp_state;
>                       size_t mbclen;
> 
> -                     if (!lexptr || lexptr >= lexend)
> -                             if (!get_src_buf()) {
> -                                     return EOF;
> -                             }
> -
>                       for (idx = 0 ; lexptr + idx < lexend ; idx++) {
>                               tmp_state = cur_mbstate;
>                               mbclen = mbrlen(lexptr, idx + 1, &tmp_state);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]