bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Problem with strftime


From: Aharon Robbins
Subject: Re: [bug-gawk] Problem with strftime
Date: Tue, 18 Oct 2011 11:35:44 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi All.

> Date: Fri, 14 Oct 2011 12:59:30 +0200
> From: Hermann Peifer <address@hidden>
> To: address@hidden
> Subject: Re: [bug-gawk] Problem with strftime
>
> On 14/10/2011 12:47, John Haque wrote:
> > On Thu, Oct 13, 2011 at 12:50:07PM -0700, Jonathan Nichols wrote:
> >> Hello,
> >>
> >>     I'm running gawk 3.1.6.  The strftime function will crash awk if
> >> the input is too big.  Here's an example of working input and
> >> non-working input:
> >>
> >> $ echo 9999999999 | awk '{print strftime("%Y-%m-%d",$1)}'
> >> 2286-11-20
> >> $ echo 13159568651306858568 | awk '{print strftime("%Y-%m-%d",$1)}'
> >> awk: (FILENAME=- FNR=1) fatal error: internal error
> >>
> >
> > Does not crash gawk 4.0. Please, consider upgrading to version 4.0.
> >
>
> $ echo 13159568651306858568 | awk '{print strftime("%Y-%m-%d",$1)}'
> awk: cmd. line:1: (FILENAME=- FNR=1) fatal error: internal error
> Aborted
> $ awk --version | head -1
> GNU Awk 4.0.0
>
> I'm on 64-bit Linux.
>
> Hermann

Thanks for the report.

Here's a fix:

diff --git a/builtin.c b/builtin.c
index 072fd8f..bae02f4 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1673,6 +1673,8 @@ do_strftime(int nargs)
                        if (do_lint && (t2->flags & (NUMCUR|NUMBER)) == 0)
                                lintwarn(_("strftime: received non-numeric 
second argument"));
                        fclock = (time_t) force_number(t2);
+                       if (fclock < 0)
+                               fatal(_("strftime: second argument less than 0 
or too big for time_t"));
                        DEREF(t2);
                }
 



reply via email to

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