freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] time parsing
- Date: Fri, 22 Jul 2005 11:35:59 +0200
>
> Hi there,
>
> thanks for freetds!
>
> I use it since 2 years and today I ran into a problem with
> 0.63 (from the
> debian package - I ran 0.61 before and it had the same problem):
>
> I'm reading a record with a datetime and I don't know why but
> a special row
> seems to contain garbage at the end:
>
> src=0xbfffe030 "Di 10 Mai 2005 14:03:43 š%S\bhàÿ¿ËÍî·8"
> (german locale)
>
If src point to row buffer this can be normal, strings in row buffer are not
null terminated.
> Then the parsing routine set the timezone to an illegal value:
>
> tm = {tm_sec = 43, tm_min = 3, tm_hour = 14, tm_mday = 10, tm_mon = 4,
> tm_year = 105, tm_wday = 2, tm_yday = 130, tm_isdst = 0,
> tm_gmtoff = 420,
> tm_zone = 0x2b <Address 0x2b out of bounds>}
>
> and the program crashed with a segmentation fault. What I did
> is to set the
> timezone explicitly. I did a call to tzset() and set
> tm.tm_zone = tzname[0]
> in convert.c in tds_strftime().
>
You are right
in tds_strftime
size_t
tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC
* dr)
{
struct tm tm;
int length = 0;
char *s, *our_format;
char millibuf[8];
char *pz = NULL;
tm.tm_sec = dr->second;
tm.tm_min = dr->minute;
tm.tm_hour = dr->hour;
tm.tm_mday = dr->day;
tm.tm_mon = dr->month;
tm.tm_year = dr->year - 1900;
tm.tm_wday = dr->weekday;
tm.tm_yday = dr->dayofyear;
tm.tm_isdst = 0;
so we do not reset tm.tm_zone ... the solution is to add a
tm.tm_zone = NULL;
line (I never though strftime could use tm_zone field).
I'll add a fix to 0.63 (and 0.64)
> I don't know if the problem is somewhere else such that this
> crazy timestamp
> gets through at all but tm_zone did not get initialized and
> it should be...
> It seems to be a gnu extension however (I'm running debian
> sarge on i386).
>
> I attach a more detailed gdb output below.
>
> A TDSDUMP-log (from another example however) is attached as well.
>
> I have another question: Is there any way I can set a
> different datestyle
> than via locale? The problem is that if you follow your locale the sql
> server might not recognize this input (i.e. its own output)
> as a valid date
> format which is pretty annoying... What do you think about
> this problem?
>
>
> Joachim
>
bye
freddy77
-
[freetds] time parsing,
Joachim Wieland, 07/22/2005
- <Possible follow-up(s)>
- Re: [freetds] time parsing, ZIGLIO, Frediano, VF-IT, 07/22/2005
- Re: [freetds] time parsing, ZIGLIO, Frediano, VF-IT, 07/22/2005
Archive powered by MHonArc 2.6.24.