Skip to Content.
Sympa Menu

freetds - RE: [freetds] some changes that I've found

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: sreynolds AT bradmark.com
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] some changes that I've found
  • Date: Wed, 05 Nov 2003 17:52:14 -0600

Hmm

On my HPUX box (HPUX 11.0), FILENAME_MAX is 14!

> >
> > I have some changes/fixes that I've found, that perhaps may
> > be useful for other
> > people too (or maybe not).
> >
> > src/odbc/prepare_query.c: Added SQL_TYPE_TIMESTAMP to
> > _get_sql_textsize().
> >
> > diff -c prepare_query.c cvs_vers\prepare_query.c
> > *** prepare_query.c Tue Nov 4 17:52:32 2003
> > --- cvs_vers\prepare_query.c Tue Nov 4 17:35:04 2003
> > ***************
> > *** 74,82 ****
> > case SQL_TIMESTAMP:
> > len = 22;
> > break;
> > - case SQL_TYPE_TIMESTAMP:
> > - len = sizeof(TIMESTAMP_STRUCT);
> > - break;
> > case SQL_NUMERIC:
> > case SQL_DECIMAL:
> > len = 34;
>
> Opps... ODBC 3 problem, however SQL_TYPE_TIMESTAMP should return same
> results of SQL_TIMESTAMP
>
> > --- 74,79 ----
> >
> >
> > src/odbc/convert_sql2string.c: Changed
> > convert_datetime2string() to add single
> > quote character surrounding the date/times in the SQL_C_TYPE_DATE,
> > SQL_C_TYPE_TIME, and SQL_C_TYPE_TIMESTMAP cases.
> >
> > src/odbc/convert_sql2string.c: convert_text2string() --
> > return a non-zero value for
> > zero length strings (zero means TDS_FAIL).
> >
> > diff -c convert_sql2string.c cvs_vers\convert_sql2string.c
> > *** convert_sql2string.c Fri Oct 31 13:35:57 2003
> > --- cvs_vers\convert_sql2string.c Mon Sep 22 15:12:50 2003
> > ***************
> > *** 150,163 ****
> > src_tm.tm_year = src_date->year - 1900;
> > src_tm.tm_mon = src_date->month - 1;
> > src_tm.tm_mday = src_date->day;
> > ! strcpy(dfmt, "'%Y-%m-%d'");
> > break;
> > case SQL_C_TIME:
> > case SQL_C_TYPE_TIME:
> > src_tm.tm_hour = src_time->hour;
> > src_tm.tm_min = src_time->minute;
> > src_tm.tm_sec = src_time->second;
> > ! strcpy(dfmt, "'%H:%M:%S'");
> > break;
> > case SQL_C_TIMESTAMP:
> > case SQL_C_TYPE_TIMESTAMP:
> > --- 150,163 ----
> > src_tm.tm_year = src_date->year - 1900;
> > src_tm.tm_mon = src_date->month - 1;
> > src_tm.tm_mday = src_date->day;
> > ! strcpy(dfmt, "%Y-%m-%d");
> > break;
> > case SQL_C_TIME:
> > case SQL_C_TYPE_TIME:
> > src_tm.tm_hour = src_time->hour;
> > src_tm.tm_min = src_time->minute;
> > src_tm.tm_sec = src_time->second;
> > ! strcpy(dfmt, "%H:%M:%S");
> > break;
> > case SQL_C_TIMESTAMP:
> > case SQL_C_TYPE_TIMESTAMP:
> > ***************
> > *** 167,173 ****
> > src_tm.tm_hour = src_timestamp->hour;
> > src_tm.tm_min = src_timestamp->minute;
> > src_tm.tm_sec = src_timestamp->second;
> > ! strcpy(dfmt, "%'Y-%m-%d %H:%M:%S'");
> > break;
> > default:
> > return TDS_FAIL;
> > --- 167,173 ----
> > src_tm.tm_hour = src_timestamp->hour;
> > src_tm.tm_min = src_timestamp->minute;
> > src_tm.tm_sec = src_timestamp->second;
> > ! strcpy(dfmt, "%Y-%m-%d %H:%M:%S");
> > break;
> > default:
> > return TDS_FAIL;
>
> Same problem
>
> > ***************
> > *** 194,202 ****
> > if (destlen >= 0 && destlen < srclen)
> > return TDS_FAIL;
> >
> > - if (srclen == 0) {
> > - return TDS_FAIL+1;
> > - }
> > memcpy(dest, src, srclen);
> >
> > return srclen;
> > --- 194,199 ----
> >
>
> convert functions should returned TDS_CONVERT_FAIL, not TDS_FAIL... I'll
> update it.
> Note however that recent snapshot do not use that code.
>
> >
> > src/odbc/connectparams.c: Change odbc_get_dsn_info(). The
> > char array tmp was
> > too small which caused a crash when the array was overrun by
> > a long error mesage.
> > Was FILENAME_MAX, change to FILENAME_MAX + 512.
> >
>
> "long error message" ?? FILENAME_MAX is 4095 on Linux and
> SQLGetPrivateProfileString do not return any error, I don't understand
> where the overflow can occur...
>
> > diff -c connectparams.c cvs_vers\connectparams.c
> > *** connectparams.c Fri Oct 31 13:51:40 2003
> > --- cvs_vers\connectparams.c Wed Sep 3 14:04:14 2003
> > ***************
> > *** 99,105 ****
> > int
> > odbc_get_dsn_info(const char *DSN, TDSCONNECTINFO * connect_info)
> > {
> > ! char tmp[FILENAME_MAX+512];
> > int freetds_conf_less = 1;
> > int address_specified = 0;
> >
> > --- 99,105 ----
> > int
> > odbc_get_dsn_info(const char *DSN, TDSCONNECTINFO * connect_info)
> > {
> > ! char tmp[FILENAME_MAX];
> > int freetds_conf_less = 1;
> > int address_specified = 0;
> >
> >
>
> bye
> freddy77
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds


--
Steven Reynolds Bradmark Technologies
sreynolds AT bradmark.com http://www.bradmark.com
713-513-9314






Archive powered by MHonArc 2.6.24.

Top of Page