Skip to Content.
Sympa Menu

freetds - Re: Bizarre date wraparound bug

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "'TDS Development Group'" <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Bizarre date wraparound bug
  • Date: Wed, 17 Oct 2001 15:11:41 -0400

Brian,

I've attached a file of what'd I say is an improved version of
tds_convert_datetime. It dereferences the source pointer instead of assuming
the structure and copying the locations. And it fails if it can't convert
the date. (I like my errors noisy.)

I'll work on extra-epoch date handling to replace the error branch. The
within-epoch branch will no doubt be faster and should remain.

What's the preferred way for tdslib to notify the user it can't do
something? Write to stderr? Write to the system log? Shut up and pray?

--jkl


-----Original Message-----
From: Brian Bruns [mailto:camber AT ais.org]
Sent: October 16, 2001 7:09 PM
To: TDS Development Group
Subject: [freetds] Re: Bizarre date wraparound bug


from src/tds/convert.c:

TDS_INT tds_convert_datetime(int srctype,unsigned char *src,int
desttype,unsigned char *dest,TDS_INT destlen)
{
TDS_INT dtdays, dttime;
time_t tmp_secs_from_epoch;

switch(desttype) {
case SYBCHAR:
case SYBVARCHAR:
/* FIX ME -- This fails for dates before 1902 or after 2038 */
if (destlen<0) {
memset(dest,' ',30);
} else {
memset(dest,' ',destlen);
}
if (!src) {
*dest='\0';
return 0;
}
memcpy(&dtdays, src, 4);
memcpy(&dttime, src+4, 4);


Anybody wanna take a crack at fixing it?

On Tue, 16 Oct 2001, Craig Davison wrote:

> On Tue, 16 Oct 2001, Michael Peppler wrote:
>
> > I guess FreeTDS takes a short cut and converts the data to standard
> > time_t format (which is OK for most things, of course).
>
> Sorry for the numerous posts, but maybe this should be in the FAQ?
>
> Thanks for your reply.
>
>


---
You are currently subscribed to freetds as: [LowdenJK AT bernstein.com]
To unsubscribe, forward this message to
$subst('Email.Unsub')

Attachment: tds_convert_datetime.c
Description: Binary data




Archive powered by MHonArc 2.6.24.

Top of Page