Re: possible when setting the timezone

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nick Martens <nick80(at)xs4all(dot)nl>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: possible when setting the timezone
Date: 2006-01-10 20:19:56
Message-ID: 3726.1136924396@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Nick Martens <nick80(at)xs4all(dot)nl> writes:
> i just tried the commands from the psql console, and seems to crash then too.

It turns out that the problem is specific to referencing a timezone name
that is a directory (rather than an individual datafile) in the timezone
database. In that case the tzload function manages to clobber some
state before realizing that it's looking at invalid data. Here's the
patch if you need it.

regards, tom lane

Index: localtime.c
===================================================================
RCS file: /cvsroot/pgsql/src/timezone/localtime.c,v
retrieving revision 1.9
diff -c -r1.9 localtime.c
*** localtime.c 1 Nov 2004 21:34:44 -0000 1.9
--- localtime.c 10 Jan 2006 20:05:06 -0000
***************
*** 842,862 ****
bool
pg_tzset(const char *name)
{
if (lcl_is_set && strcmp(lcl_TZname, name) == 0)
return true; /* no change */

if (strlen(name) >= sizeof(lcl_TZname))
return false; /* not gonna fit */

! if (tzload(name, lclptr) != 0)
{
! if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
{
/* Unknown timezone. Fail our call instead of loading GMT! */
return false;
}
}

strcpy(lcl_TZname, name);
lcl_is_set = true;

--- 842,865 ----
bool
pg_tzset(const char *name)
{
+ struct state tmpmem;
+
if (lcl_is_set && strcmp(lcl_TZname, name) == 0)
return true; /* no change */

if (strlen(name) >= sizeof(lcl_TZname))
return false; /* not gonna fit */

! if (tzload(name, &tmpmem) != 0)
{
! if (name[0] == ':' || tzparse(name, &tmpmem, FALSE) != 0)
{
/* Unknown timezone. Fail our call instead of loading GMT! */
return false;
}
}

+ memcpy(lclptr, &tmpmem, sizeof(struct state));
strcpy(lcl_TZname, name);
lcl_is_set = true;

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-01-10 21:15:53 Re: INSERT causes psql to crash
Previous Message Jim C. Nasby 2006-01-10 20:14:19 Re: Reordering columns in a table