Bug#413534: odbc-postgresql: odbc driver broken on 64 bit architectures

2007-03-17 Thread Steve Langasek
tags 413534 patch
thanks

Hi Peter,

I've had a chance now to look over Stephen's proposed bugfix.  I haven't
verified that this is a complete fix for all related 64-bit issues, but I
agree that there are 64-bit problems in this code and that his/upstream's
changes appear to be a correct, minimal fix for the problem he's running
into.

I'm therefore going to go ahead and NMU a fix for this bug using Stephen's
patch.  The full NMU diff is attached; it will be uploaded to incoming
shortly.

Thanks,
-- 
Steve Langasek   Give me a lever long enough and a Free OS
Debian Developer   to set it on, and I can move the world.
[EMAIL PROTECTED]   http://www.debian.org/
diff -u psqlodbc-08.01.0200/debian/changelog psqlodbc-08.01.0200/debian/changelog
--- psqlodbc-08.01.0200/debian/changelog
+++ psqlodbc-08.01.0200/debian/changelog
@@ -1,3 +1,11 @@
+psqlodbc (1:08.01.0200-2.1) unstable; urgency=high
+
+  * Non-maintainer upload.
+  * High-urgency upload for RC bugfix.
+  * Fix the signature of SQLGetData on 64-bit architectures.
+
+ -- Steve Langasek [EMAIL PROTECTED]  Mon,  5 Mar 2007 22:28:19 -0800
+
 psqlodbc (1:08.01.0200-2) unstable; urgency=low
 
   * Fix to build on 64-bit architectures (closes: #358949)
only in patch2:
unchanged:
--- psqlodbc-08.01.0200.orig/debian/patches/psqlodbc-413534.diff
+++ psqlodbc-08.01.0200/debian/patches/psqlodbc-413534.diff
@@ -0,0 +1,135 @@
+diff -ur psqlodbc-08.01.0200.orig/convert.c psqlodbc-08.01.0200/convert.c
+--- psqlodbc-08.01.0200.orig/convert.c	2007-03-07 12:10:01.0 -0500
 psqlodbc-08.01.0200/convert.c	2007-03-07 12:10:17.0 -0500
+@@ -379,14 +379,14 @@
+ 
+ 	SC_set_current_col(stmt, -1);
+ 	return copy_and_convert_field(stmt, field_type, value, (Int2) bic-returntype, (PTR) (bic-buffer + offset),
+-			 (SDWORD) bic-buflen, (bic-used + (offset  2)));
++			 bic-buflen, (bic-used + (offset  2)));
+ }
+ 
+ 
+ /*	This is called by SQLGetData() */
+ int
+ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2 fCType,
+-	   PTR rgbValue, SDWORD cbValueMax, SQLLEN *pcbValue)
++	   PTR rgbValue, SQLLEN cbValueMax, SQLLEN *pcbValue)
+ {
+ 	CSTR func = copy_and_convert_field;
+ 	ARDFields	*opts = SC_get_ARDF(stmt);
+@@ -454,7 +454,7 @@
+ 		pcbValueOffset = rgbValueOffset = (bind_size * bind_row);
+ 	else
+ 	{
+-		pcbValueOffset = bind_row * sizeof(SDWORD);
++		pcbValueOffset = bind_row * sizeof(SQLLEN);
+ 		rgbValueOffset = bind_row * cbValueMax;
+ 	}
+ 	/*
+@@ -486,7 +486,7 @@
+ 		 */
+ 		if (pcbValue)
+ 		{
+-			*((SDWORD *) pcbValueBindRow) = SQL_NULL_DATA;
++			*((SQLLEN *) pcbValueBindRow) = SQL_NULL_DATA;
+ 			return COPY_OK;
+ 		}
+ 		else
+@@ -663,7 +663,7 @@
+ 
+ /* There is no corresponding fCType for this. */
+ if (pcbValue)
+-	*((SDWORD *) pcbValueBindRow) = len;
++	*((SQLLEN *) pcbValueBindRow) = len;
+ 
+ return COPY_OK; /* dont go any further or the data will be
+  * trashed */
+@@ -675,13 +675,13 @@
+ 			 */
+ 		case PG_TYPE_LO_UNDEFINED:
+ 
+-			return convert_lo(stmt, value, fCType, rgbValueBindRow, cbValueMax, (SDWORD *) pcbValueBindRow);
++			return convert_lo(stmt, value, fCType, rgbValueBindRow, cbValueMax, (SQLLEN *) pcbValueBindRow);
+ 
+ 		default:
+ 
+ 			if (field_type == stmt-hdbc-lobj_type)	/* hack until permanent
+ 		 * type available */
+-return convert_lo(stmt, value, fCType, rgbValueBindRow, cbValueMax, (SDWORD *) pcbValueBindRow);
++return convert_lo(stmt, value, fCType, rgbValueBindRow, cbValueMax, (SQLLEN *) pcbValueBindRow);
+ 	}
+ 
+ 	/* Change default into something useable */
+@@ -956,13 +956,13 @@
+ 			{
+ char *str = strdup(rgbValueBindRow);
+ UInt4	ucount = utf8_to_ucs2(str, len, (SQLWCHAR *) rgbValueBindRow, cbValueMax / WCLEN);
+-if (cbValueMax  (SDWORD) (WCLEN * ucount))
++if (cbValueMax  WCLEN * ucount)
+ 	result = COPY_RESULT_TRUNCATED;
+ free(str); 
+ 			}
+ 			else
+ 			{
+-if ((SDWORD) (len + WCLEN) = cbValueMax)
++if (len + WCLEN = cbValueMax)
+ {
+ result = COPY_OK;
+ }
+@@ -1263,7 +1263,7 @@
+ 	if (neut_str)
+ 		len = strlen(neut_str);
+ 	if (pcbValue)
+-		*((SDWORD *) pcbValueBindRow) = len;
++		*((SQLLEN *) pcbValueBindRow) = len;
+ 	if (len  0  cbValueMax  0)
+ 	{
+ 		memcpy(rgbValueBindRow, neut_str, len  cbValueMax ? len : cbValueMax);
+@@ -1282,7 +1282,7 @@
+ 
+ inolog(SQL_C_VARBOOKMARK value=%d\n, ival);
+ 	if (pcbValue)
+-		*((SDWORD *) pcbValueBindRow) = sizeof(ival);
++		*((SQLLEN *) pcbValueBindRow) = sizeof(ival);
+ 	if (cbValueMax = sizeof(ival))
+ 	{
+ 		memcpy(rgbValueBindRow, ival, sizeof(ival));
+@@ -1381,7 +1381,7 @@
+ 
+ 	/* store the length of what was copied, if there's a place for it */
+ 	if (pcbValue)
+-		*((SDWORD *) pcbValueBindRow) = len;
++		*((SQLLEN *) pcbValueBindRow) = 

Bug#413534: odbc-postgresql: odbc driver broken on 64 bit architectures

2007-03-05 Thread Package Maintainer
Package: odbc-postgresql
Version: 1:08.01.0200-2
Severity: grave
Justification: renders package unusable

The odbc driver is not 64 bit clean.  While the patch Steve provided to
enable it to build on 64 bit systems is great, it doesn't make the
driver actually work.

In particular the function I ran into the problem with is SQLGetData
which continues to take a *SQLINTEGER rather than a *SQLLEN for the
indicator.

As a result, on 64 bit systems this corrupts the calling application and
causes crashes.

There is a new upstream version which appears to fix these issues with a
little help to actually build.  the unixodbc package also provides a
PostgreSQL odbc driver which seems to not have these issues, however the
drivers in the unixodbc source package are not packaged in debian.

The new upstream version 8.02.200 works, but requires a patch to
actually build due to some bugs that have since been solved.  I'll
attach the patch that I used locally.




-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-dcc-srv
Locale: LANG=en_CA, LC_CTYPE=en_CA (charmap=ISO-8859-1) (ignored: LC_ALL set to 
en_CA)

Versions of packages odbc-postgresql depends on:
ii  libc62.3.6.ds1-11GNU C Library: Shared libraries
ii  libcomer 1.39+1.40-WIP-2006.11.14+dfsg-1 common error description library
ii  libkrb53 1.4.4-6 MIT Kerberos runtime libraries
ii  libpam0g 0.79-4  Pluggable Authentication Modules l
ii  libpq4   8.1.8-1 PostgreSQL C client library
ii  libreadl 5.2-2   GNU readline and history libraries
ii  libssl0. 0.9.8c-4SSL shared libraries
ii  odbcinst 2.2.11-13   Support library and helper program
ii  zlib1g   1:1.2.3-13  compression library - runtime

odbc-postgresql recommends no packages.

-- no debconf information
diff -ur clean/psqlodbc-08.02.0200/connection.h psqlodbc-08.02.0200/connection.h
--- clean/psqlodbc-08.02.0200/connection.h	2006-10-17 12:18:56.0 -0400
+++ psqlodbc-08.02.0200/connection.h	2007-03-05 11:24:01.0 -0500
@@ -170,11 +170,13 @@
 #define DELETE_CONNLOCK(x)	pthread_mutex_destroy(((x)-slock))
 #else
 #define INIT_CONN_CS(x)	
-#define INIT_CONN_LOCK(x)	
-#define TRY_ENTER_CONN_CS(x)
+#define INIT_CONNLOCK(x)	
 #define ENTER_CONN_CS(x)
+#define CONNLOCK_ACQUIRE(x)	
+#define TRY_ENTER_CONN_CS(x)
 #define ENTER_INNER_CONN_CS(x, entered) (0)
 #define LEAVE_CONN_CS(x)
+#define CONNLOCK_RELEASE(x)
 #define DELETE_CONN_CS(x)
 #define DELETE_CONNLOCK(x)
 #endif /* WIN_MULTITHREAD_SUPPORT */
Only in psqlodbc-08.02.0200: debian
diff -ur clean/psqlodbc-08.02.0200/odbcapi.c psqlodbc-08.02.0200/odbcapi.c
--- clean/psqlodbc-08.02.0200/odbcapi.c	2006-10-17 12:18:56.0 -0400
+++ psqlodbc-08.02.0200/odbcapi.c	2007-03-05 10:57:22.0 -0500
@@ -1103,8 +1103,8 @@
 SQLExtendedFetch(
  HSTMT hstmt,
  SQLUSMALLINT fFetchType,
- SQLLEN irow,
- SQLULEN *pcrow,
+ SQLROWOFFSET irow,
+ SQLROWSETSIZE *pcrow,
  SQLUSMALLINT *rgfRowStatus)
 {
 	RETCODE	ret;


Bug#413534: odbc-postgresql: odbc driver broken on 64 bit architectures

2007-03-05 Thread Steve Langasek
Hi Stephen,

On Mon, Mar 05, 2007 at 11:52:42AM -0500, Package Maintainer wrote:
 The odbc driver is not 64 bit clean.  While the patch Steve provided to
 enable it to build on 64 bit systems is great, it doesn't make the
 driver actually work.

 In particular the function I ran into the problem with is SQLGetData
 which continues to take a *SQLINTEGER rather than a *SQLLEN for the
 indicator.

 As a result, on 64 bit systems this corrupts the calling application and
 causes crashes.

 There is a new upstream version which appears to fix these issues with a
 little help to actually build.  the unixodbc package also provides a
 PostgreSQL odbc driver which seems to not have these issues, however the
 drivers in the unixodbc source package are not packaged in debian.

 The new upstream version 8.02.200 works, but requires a patch to
 actually build due to some bugs that have since been solved.  I'll
 attach the patch that I used locally.

Well, it's rather late in the release cycle to try to fix this with a new
upstream version.  Is fixing SQLGetData enough to make odbc-postgresql
usable on 64-bit archs, or are there other fixes needed besides?

Thanks,
-- 
Steve Langasek   Give me a lever long enough and a Free OS
Debian Developer   to set it on, and I can move the world.
[EMAIL PROTECTED]   http://www.debian.org/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]