Skip to Content.
Sympa Menu

freetds - Re: [freetds] various issues and bug fixes...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] various issues and bug fixes...
  • Date: Mon, 3 Oct 2011 12:59:27 +0200

I'll split and try to apply. Does this patch is for 0.91 or CVS HEAD ??

I noted that tds_gettime_ms is now commented out, "fix" for
challenge.c only remove a warning for some compiler and sqlwstr is not
reentrant.

Regards,
Frediano

2011/9/29 Christos Zoulas <christos AT zoulas.com>:
>
> Hi,
>
> a. Deal with kerberos and heimdal. If we enabled krb5 and we found
>   its libraries add any of the existing /usr/include/krb5
>   /usr/include/heimdal /usr/include/et to CPPFLAGS
> b. check if error_message() exists, if not supply one.
> c. include roken.h because getipnode*() is supplied by heimdal on
>   systems that don't have it, so we don't get prototypes for them
>   since they are not included in the standard headers.
> d. include com_err.h for error_message().
> e. add missing prototype for tds_gettime_ms.
> f. fix uninitialized variable in challenge.c.
> g. wide odbc wouldn't even compile. Deal with string printing properly.
>   1. define ODBC_STRING and ODBC_STRING_FORMAT to abstract the wide/non-wide
>      how to retrieve a string and format.
>   2. on systems where sizeof(wchar_t) is not equal to sizeof(SQLWHAR_T)
>      supply a conversion function.
>   3. fix incorrect cast.
>   4. silence warnings about integer casts of different size to pointer,
>      annotate them XXX, since they cannot possibly work.
>
>
> christos
>
> Index: configure.ac
> ===================================================================
> RCS file: /src/twosigma/cvsroot/external/public/freetds/configure.ac,v
> retrieving revision 1.9
> diff -u -u -r1.9 configure.ac
> --- configure.ac        29 Sep 2011 16:37:13 -0000      1.9
> +++ configure.ac        29 Sep 2011 19:24:11 -0000
> @@ -199,6 +199,16 @@
>        ;;
>  esac
>
> +if test -n "$krb5_libs"
> +then
> +       for d in /usr/include/heimdal /usr/include/krb5 /usr/include/et; do
> +               if test -d "$d"; then
> +                       CPPFLAGS="$CPPFLAGS -I$d"
> +               fi
> +       done
> +       AC_CHECK_FUNCS([error_message])
> +fi
> +
>  NETWORK_LIBS="$LIBS"
>  LIBS="$OLDLIBS"
>  AC_SUBST(NETWORK_LIBS)
> @@ -296,6 +306,8 @@
>                        netdb.h \
>                        netinet/in.h \
>                        netinet/tcp.h \
> +                       roken.h \
> +                       com_err.h \
>                        paths.h \
>                        sys/ioctl.h \
>                        sys/socket.h ])
> Index: include/tds.h
> ===================================================================
> RCS file: /src/twosigma/cvsroot/external/public/freetds/include/tds.h,v
> retrieving revision 1.18
> diff -u -u -r1.18 tds.h
> --- include/tds.h       29 Sep 2011 16:37:18 -0000      1.18
> +++ include/tds.h       29 Sep 2011 19:24:11 -0000
> @@ -1214,6 +1214,8 @@
>  int tdserror (const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, int msgno, int
> errnum);
>  TDS_STATE tds_set_state(TDSSOCKET * tds, TDS_STATE state);
>  int tds_swap_bytes(unsigned char *buf, int bytes);
> +unsigned int tds_gettime_ms(void);
> +
>
>  /* log.c */
>  void tdsdump_off(void);
> Index: include/tdsodbc.h
> ===================================================================
> RCS file: /src/twosigma/cvsroot/external/public/freetds/include/tdsodbc.h,v
> retrieving revision 1.8
> diff -u -u -r1.8 tdsodbc.h
> --- include/tdsodbc.h   29 Sep 2011 16:37:18 -0000      1.8
> +++ include/tdsodbc.h   29 Sep 2011 19:24:11 -0000
> @@ -578,10 +578,14 @@
>        char mb[1];
>        SQLWCHAR wide[1];
>  } ODBC_CHAR;
> +# define ODBC_STRING_FORMAT "%ls"
> +# define ODBC_STRING(a) sqlwstr((a)->wide)
>  # define _wide ,wide
>  # define _wide0 ,0
>  # define _WIDE ,int wide
>  #else
> +# define ODBC_STRING_FORMAT "%s"
> +# define ODBC_STRING(a) (a)
>  # define _wide
>  # define _wide0
>  # define _WIDE
> @@ -656,8 +660,10 @@
>  */
>  #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T
>  size_t sqlwcslen(const SQLWCHAR * s);
> +const wchar_t *sqlwstr(const SQLWCHAR * s);
>  #else
> -#define sqlwcslen wcslen
> +#define sqlwcslen(s) wcslen(s)
> +#define sqlwstr(s) (s)
>  #endif
>
>  #if SIZEOF_SQLWCHAR == 2
> Index: src/odbc/odbc.c
> ===================================================================
> RCS file: /src/twosigma/cvsroot/external/public/freetds/src/odbc/odbc.c,v
> retrieving revision 1.7
> diff -u -u -r1.7 odbc.c
> --- src/odbc/odbc.c     29 Sep 2011 16:37:19 -0000      1.7
> +++ src/odbc/odbc.c     29 Sep 2011 19:24:11 -0000
> @@ -522,8 +522,11 @@
>
>        INIT_HDBC;
>
> -       tdsdump_log(TDS_DBG_FUNC, "SQLDriverConnect(%p, %p, %s, %d, %p, %d,
> %p, %d)\n",
> -                       hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut,
> cbConnStrOutMax, pcbConnStrOut, fDriverCompletion);
> +       tdsdump_log(TDS_DBG_FUNC, "SQLDriverConnect(%p, %p, "
> ODBC_STRING_FORMAT
> +                   ", %d, %p, %d, %p, %d)\n",
> +                   hdbc, hwnd, ODBC_STRING(szConnStrIn), cbConnStrIn,
> +                   szConnStrOut, cbConnStrOutMax, pcbConnStrOut,
> +                   fDriverCompletion);
>
>  #ifdef TDS_NO_DM
>        /* Check string length */
> @@ -965,8 +968,10 @@
>
>        INIT_HDBC;
>
> -       tdsdump_log(TDS_DBG_FUNC, "SQLNativeSql(%p, %s, %d, %p, %d, %p)\n",
> -                       hdbc, szSqlStrIn, (int)cbSqlStrIn, szSqlStr,
> (int)cbSqlStrMax, pcbSqlStr);
> +       tdsdump_log(TDS_DBG_FUNC, "SQLNativeSql(%p, " ODBC_STRING_FORMAT
> +                   ", %d, %p, %d, %p)\n",
> +                   hdbc, ODBC_STRING(szSqlStrIn), (int)cbSqlStrIn,
> szSqlStr,
> +                   (int)cbSqlStrMax, pcbSqlStr);
>
>        tds_dstr_init(&query);
>
> @@ -2783,7 +2788,7 @@
>                result = SQL_ERROR;
>                break;
>        case SQL_DESC_NAME:
> -               if (!odbc_dstr_copy_oct(desc_get_dbc(desc),
> &drec->sql_desc_name, BufferLength, (SQLCHAR*) Value)) {
> +               if (!odbc_dstr_copy_oct(desc_get_dbc(desc),
> &drec->sql_desc_name, BufferLength, (ODBC_CHAR*) Value)) {
>                        odbc_errs_add(&desc->errs, "HY001", NULL);
>                        result = SQL_ERROR;
>                }
> @@ -4444,7 +4449,8 @@
>
>        INIT_HSTMT;
>
> -       tdsdump_log(TDS_DBG_FUNC, "SQLPrepare(%p, %s, %d)\n", hstmt,
> szSqlStr, (int)cbSqlStr);
> +       tdsdump_log(TDS_DBG_FUNC, "SQLPrepare(%p, " ODBC_STRING_FORMAT
> +                   ", %d)\n", hstmt, ODBC_STRING(szSqlStr), (int)cbSqlStr);
>
>        /* try to free dynamic associated */
>        retcode = odbc_free_dynamic(stmt);
> @@ -4694,8 +4700,13 @@
>
>        INIT_HSTMT;
>
> -       tdsdump_log(TDS_DBG_FUNC, "SQLColumns(%p, %s, %d, %s, %d, %s, %d,
> %s, %d)\n",
> -                       hstmt, szCatalogName, cbCatalogName, szSchemaName,
> cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName);
> +       tdsdump_log(TDS_DBG_FUNC, "SQLColumns(%p, " ODBC_STRING_FORMAT ",
> %d, "
> +                   ODBC_STRING_FORMAT ", %d, " ODBC_STRING_FORMAT ", %d, "
> +                   ODBC_STRING_FORMAT ", %d)\n",
> +                   hstmt, ODBC_STRING(szCatalogName), cbCatalogName,
> +                   ODBC_STRING(szSchemaName), cbSchemaName,
> +                   ODBC_STRING(szTableName), cbTableName,
> +                   ODBC_STRING(szColumnName), cbColumnName);
>
>        retcode =
>                odbc_stat_execute(stmt _wide, "sp_columns",
> TDS_IS_MSSQL(stmt->dbc->tds_socket) ? 5 : 4,
> @@ -6201,7 +6212,8 @@
>  SQLSetConnectOption(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLULEN vParam)
>  {
>        tdsdump_log(TDS_DBG_FUNC, "SQLSetConnectOption(%p, %d, %u)\n", hdbc,
> fOption, (unsigned)vParam);
> -       return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER)
> vParam, SQL_NTS _wide0);
> +       /* XXX: Lost precision */
> +       return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER)
> (TDS_INTPTR) vParam, SQL_NTS _wide0);
>  }
>
>  #ifdef ENABLE_ODBC_WIDE
> @@ -6209,7 +6221,8 @@
>  SQLSetConnectOptionW(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLULEN vParam)
>  {
>        tdsdump_log(TDS_DBG_FUNC, "SQLSetConnectOptionW(%p, %d, %u)\n",
> hdbc, fOption, (unsigned)vParam);
> -       return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER)
> vParam, SQL_NTS, 1);
> +       /* XXX: Lost precision */
> +       return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER)
> (TDS_INTPTR) vParam, SQL_NTS, 1);
>  }
>  #endif
>
> @@ -6520,7 +6533,8 @@
>  {
>        tdsdump_log(TDS_DBG_FUNC, "SQLSetStmtOption(%p, %u, %u)\n", hstmt,
> fOption, (unsigned)vParam);
>
> -       return _SQLSetStmtAttr(hstmt, (SQLINTEGER) fOption, (SQLPOINTER)
> vParam, SQL_NTS);
> +       /* XXX: Lost precision */
> +       return _SQLSetStmtAttr(hstmt, (SQLINTEGER) fOption, (SQLPOINTER)
> (TDS_INTPTR) vParam, SQL_NTS);
>  }
>
>  #define FUNC NAME(SQLSpecialColumns) (P(SQLHSTMT,hstmt),
> P(SQLUSMALLINT,fColType), PCHARIN(CatalogName,SQLSMALLINT), \
> Index: src/odbc/sqlwchar.c
> ===================================================================
> RCS file:
> /src/twosigma/cvsroot/external/public/freetds/src/odbc/sqlwchar.c,v
> retrieving revision 1.1.1.5
> diff -u -u -r1.1.1.5 sqlwchar.c
> --- src/odbc/sqlwchar.c 29 Sep 2011 16:34:50 -0000      1.1.1.5
> +++ src/odbc/sqlwchar.c 29 Sep 2011 19:24:11 -0000
> @@ -35,5 +35,17 @@
>                ++p;
>        return p - s;
>  }
> +
> +const wchar_t *sqlwstr(const SQLWCHAR *s)
> +{
> +       static wchar_t buf[1024], *eb = buf + sizeof(buf) - 1;
> +       wchar_t *p;
> +
> +       for (p = buf; *s && p < eb; *p++ = *s++)
> +               continue;
> +       *p = '\0';
> +
> +       return buf;
> +}
>  #endif
>
> Index: src/tds/challenge.c
> ===================================================================
> RCS file:
> /src/twosigma/cvsroot/external/public/freetds/src/tds/challenge.c,v
> retrieving revision 1.1.1.13
> diff -u -u -r1.1.1.13 challenge.c
> --- src/tds/challenge.c 29 Sep 2011 16:34:50 -0000      1.1.1.13
> +++ src/tds/challenge.c 29 Sep 2011 19:24:11 -0000
> @@ -640,7 +640,7 @@
>        int data_block_offset;
>
>        int target_info_len = 0;
> -       int target_info_offset;
> +       int target_info_offset = 0;
>
>        int names_blob_len;
>        unsigned char *names_blob;
> Index: src/tds/gssapi.c
> ===================================================================
> RCS file: /src/twosigma/cvsroot/external/public/freetds/src/tds/gssapi.c,v
> retrieving revision 1.1.1.5
> diff -u -u -r1.1.1.5 gssapi.c
> --- src/tds/gssapi.c    29 Sep 2011 16:34:50 -0000      1.1.1.5
> +++ src/tds/gssapi.c    29 Sep 2011 19:24:11 -0000
> @@ -53,6 +53,10 @@
>  #include <arpa/inet.h>
>  #endif /* HAVE_ARPA_INET_H */
>
> +#if HAVE_COM_ERR_H
> +#include <com_err.h>
> +#endif /* HAVE_COM_ERR_H */
> +
>  #ifdef ENABLE_KRB5
>
>  #include <gssapi/gssapi_krb5.h>
> @@ -249,6 +253,16 @@
>
>        return (TDSAUTHENTICATION *) auth;
>  }
> +
> +#ifndef HAVE_ERROR_MESSAGE
> +static const char *
> +error_message(OM_uint32 e)
> +{
> +       const char *m = strerror(e);
> +       if (m == NULL)
> +               return "";
> +}
> +#endif
>
>  static TDSRET
>  tds_gss_continue(TDSSOCKET * tds, struct tds_gss_auth *auth,
> gss_buffer_desc *token_ptr)
> Index: src/tds/threadsafe.c
> ===================================================================
> RCS file:
> /src/twosigma/cvsroot/external/public/freetds/src/tds/threadsafe.c,v
> retrieving revision 1.1.1.13
> diff -u -u -r1.1.1.13 threadsafe.c
> --- src/tds/threadsafe.c        29 Sep 2011 16:34:50 -0000      1.1.1.13
> +++ src/tds/threadsafe.c        29 Sep 2011 19:24:11 -0000
> @@ -72,6 +72,10 @@
>  #include <arpa/inet.h>
>  #endif /* HAVE_ARPA_INET_H */
>
> +#if HAVE_ROKEN_H
> +#include <roken.h>
> +#endif /* HAVE_ROKEN_H */
> +
>  #if defined(_WIN32) || defined(_WIN64)
>  #include <winsock2.h>
>  #include <shlobj.h>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>



  • Re: [freetds] various issues and bug fixes..., Frediano Ziglio, 10/03/2011

Archive powered by MHonArc 2.6.24.

Top of Page