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

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

too long source lines that are in error can core dump gawk 3.1.0


From: Aharon Robbins
Subject: too long source lines that are in error can core dump gawk 3.1.0
Date: Wed, 7 Nov 2001 16:54:51 +0200

> To: address@hidden
> Subject: found awk "internal error"
> Date: Tue, 30 Oct 2001 12:39:40 +0800 (CST)
> From: Dan Jacobson
>
> I don't know that it was importaint, but i thought you should know...
> it said "internal error" so I thoght you should know...
> it is a product of some symple typo that i will now fix...

It was a memory overrun.  In keeping with the "no arbitrary limits"
principle of GNU software, this is now fixed.  Thanks for the report,
and here's a patch.

Arnold
---------------------------------------------------------------
*** ../gawk-3.1.0/awkgram.y     Mon Apr 23 10:25:58 2001
--- awkgram.y   Wed Nov  7 16:46:01 2001
***************
*** 1006,1015 ****
        const char *mesg = NULL;
        register char *bp, *cp;
        char *scan;
-       char buf[120];
        static char end_of_file_line[] = "(END OF FILE)";
  
        errcount++;
        /* Find the current line in the input file */
        if (lexptr && lexeme) {
                if (thisline == NULL) {
--- 1006,1015 ----
        const char *mesg = NULL;
        register char *bp, *cp;
        char *scan;
        static char end_of_file_line[] = "(END OF FILE)";
  
        errcount++;
+ 
        /* Find the current line in the input file */
        if (lexptr && lexeme) {
                if (thisline == NULL) {
***************
*** 1032,1050 ****
                thisline = end_of_file_line;
                bp = thisline + strlen(thisline);
        }
        msg("%.*s", (int) (bp - thisline), thisline);
!       bp = buf;
!       cp = buf + sizeof(buf) - 24;    /* 24 more than longest msg. input */
        if (lexptr != NULL) {
!               scan = thisline;
!               while (bp < cp && scan < lexeme)
                        if (*scan++ == '\t')
!                               *bp++ = '\t';
                        else
!                               *bp++ = ' ';
!               *bp++ = '^';
!               *bp++ = ' ';
        }
  #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
        va_start(args, m);
        if (mesg == NULL)
--- 1032,1054 ----
                thisline = end_of_file_line;
                bp = thisline + strlen(thisline);
        }
+ 
+       /* print it */
        msg("%.*s", (int) (bp - thisline), thisline);
! 
!       /* prepend white space and `^ ' */
        if (lexptr != NULL) {
!               for (scan = thisline; scan < lexeme; scan++)
                        if (*scan++ == '\t')
!                               putc('\t', stderr);
                        else
!                               putc(' ', stderr);
!               putc('^', stderr);
!               putc(' ', stderr);
        }
+ 
+ 
+       /* get error message format string */
  #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
        va_start(args, m);
        if (mesg == NULL)
***************
*** 1054,1061 ****
        if (mesg == NULL)
                mesg = va_arg(args, char *);
  #endif
!       strcpy(bp, mesg);
!       err("", buf, args);
        va_end(args);
  }
  
--- 1058,1066 ----
        if (mesg == NULL)
                mesg = va_arg(args, char *);
  #endif
! 
!       /* print error message and arguments */
!       err("", mesg, args);
        va_end(args);
  }
  



reply via email to

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