Re: possible when setting the timezone

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: possible when setting the timezone
Дата
Msg-id 3726.1136924396@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: possible when setting the timezone  (Nick Martens <nick80@xs4all.nl>)
Список pgsql-bugs
Nick Martens <nick80@xs4all.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;

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Juan Pablo Yañez
Дата:
Сообщение: Unsuscribe
Следующее
От: Tom Lane
Дата:
Сообщение: Re: INSERT causes psql to crash