[unixODBC/f19] Fix assorted small bugs found by Coverity
Tom Lane
tgl at fedoraproject.org
Tue Mar 19 18:11:16 UTC 2013
commit c00ec4af81e86901face97823cb6843e7a6b1115
Author: Tom Lane <tgl at redhat.com>
Date: Tue Mar 19 13:41:16 2013 -0400
Fix assorted small bugs found by Coverity
coverity-fixes.patch | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++
unixODBC.spec | 8 +++-
2 files changed, 132 insertions(+), 1 deletions(-)
---
diff --git a/coverity-fixes.patch b/coverity-fixes.patch
new file mode 100644
index 0000000..e024519
--- /dev/null
+++ b/coverity-fixes.patch
@@ -0,0 +1,125 @@
+Fix assorted small errors detected by a Coverity scan, per bug #760877.
+
+
+diff -Naur unixODBC-2.3.1.orig/DriverManager/SQLGetCursorName.c unixODBC-2.3.1/DriverManager/SQLGetCursorName.c
+--- unixODBC-2.3.1.orig/DriverManager/SQLGetCursorName.c 2011-08-04 09:06:56.000000000 -0400
++++ unixODBC-2.3.1/DriverManager/SQLGetCursorName.c 2013-03-19 13:12:19.022156796 -0400
+@@ -189,7 +189,7 @@
+
+ thread_protect( SQL_HANDLE_STMT, statement );
+
+- if ( !buffer_length < 0 )
++ if ( !(buffer_length < 0) )
+ {
+ dm_log_write( __FILE__,
+ __LINE__,
+diff -Naur unixODBC-2.3.1.orig/DriverManager/SQLGetCursorNameW.c unixODBC-2.3.1/DriverManager/SQLGetCursorNameW.c
+--- unixODBC-2.3.1.orig/DriverManager/SQLGetCursorNameW.c 2011-08-04 09:07:01.000000000 -0400
++++ unixODBC-2.3.1/DriverManager/SQLGetCursorNameW.c 2013-03-19 13:12:19.023156773 -0400
+@@ -172,7 +172,7 @@
+
+ thread_protect( SQL_HANDLE_STMT, statement );
+
+- if ( !buffer_length < 0 )
++ if ( !(buffer_length < 0) )
+ {
+ dm_log_write( __FILE__,
+ __LINE__,
+diff -Naur unixODBC-2.3.1.orig/DriverManager/__info.c unixODBC-2.3.1/DriverManager/__info.c
+--- unixODBC-2.3.1.orig/DriverManager/__info.c 2011-11-15 06:43:15.000000000 -0500
++++ unixODBC-2.3.1/DriverManager/__info.c 2013-03-19 13:12:19.022156796 -0400
+@@ -3997,7 +3997,7 @@
+
+ void setup_error_head( EHEAD *error_header, void *handle, int type )
+ {
+- memset( error_header, 0, sizeof( error_header ));
++ memset( error_header, 0, sizeof( *error_header ));
+
+ error_header -> owning_handle = handle;
+ error_header -> handle_type = type;
+diff -Naur unixODBC-2.3.1.orig/Drivers/Postgre7.1/info.c unixODBC-2.3.1/Drivers/Postgre7.1/info.c
+--- unixODBC-2.3.1.orig/Drivers/Postgre7.1/info.c 2009-12-11 11:54:08.000000000 -0500
++++ unixODBC-2.3.1/Drivers/Postgre7.1/info.c 2013-03-19 13:12:19.025156733 -0400
+@@ -1007,7 +1007,7 @@
+ strcpy(prefixes, globals.extra_systable_prefixes);
+ i = 0;
+ prefix[i] = strtok(prefixes, ";");
+- while (prefix[i] && i<32) {
++ while (prefix[i] && i<sizeof(prefix)-1) {
+ prefix[++i] = strtok(NULL, ";");
+ }
+
+@@ -1023,7 +1023,7 @@
+ free(tableType);
+ i = 0;
+ table_type[i] = strtok(table_types, ",");
+- while (table_type[i] && i<32) {
++ while (table_type[i] && i<sizeof(table_type)-1) {
+ table_type[++i] = strtok(NULL, ",");
+ }
+
+diff -Naur unixODBC-2.3.1.orig/Drivers/nn/convert.c unixODBC-2.3.1/Drivers/nn/convert.c
+--- unixODBC-2.3.1.orig/Drivers/nn/convert.c 2009-12-11 11:54:09.000000000 -0500
++++ unixODBC-2.3.1/Drivers/nn/convert.c 2013-03-19 13:12:19.024156752 -0400
+@@ -246,7 +246,7 @@
+ if( cidx == -1 )
+ return 0;
+
+- for(i=0; i< sizeof(ctype_idx_tab); i++ )
++ for(i=0; i< sizeof(sqltype_idx_tab); i++ )
+ {
+ if( sqltype_idx_tab[i].sqltype == sqltype )
+ {
+@@ -432,7 +432,7 @@
+ if( cidx == -1 )
+ return 0;
+
+- for(i=0; i< sizeof(ctype_idx_tab); i++ )
++ for(i=0; i< sizeof(sqltype_idx_tab); i++ )
+ {
+ if( sqltype_idx_tab[i].sqltype == sqltype )
+ {
+diff -Naur unixODBC-2.3.1.orig/cur/SQLBindCol.c unixODBC-2.3.1/cur/SQLBindCol.c
+--- unixODBC-2.3.1.orig/cur/SQLBindCol.c 2011-08-04 09:11:51.000000000 -0400
++++ unixODBC-2.3.1/cur/SQLBindCol.c 2013-03-19 13:12:19.019156876 -0400
+@@ -90,7 +90,7 @@
+ {
+ CLBCOL *next;
+
+- if ( bcol -> local_buffer );
++ if ( bcol -> local_buffer )
+ {
+ free( bcol -> local_buffer );
+ }
+diff -Naur unixODBC-2.3.1.orig/cur/SQLGetInfo.c unixODBC-2.3.1/cur/SQLGetInfo.c
+--- unixODBC-2.3.1.orig/cur/SQLGetInfo.c 2011-08-04 09:13:48.000000000 -0400
++++ unixODBC-2.3.1/cur/SQLGetInfo.c 2013-03-19 13:12:19.020156848 -0400
+@@ -140,6 +140,7 @@
+ value = SQL_PS_POSITIONED_DELETE |
+ SQL_PS_POSITIONED_UPDATE |
+ SQL_PS_SELECT_FOR_UPDATE;
++ break;
+
+ case SQL_ROW_UPDATES:
+ cval = "Y";
+diff -Naur unixODBC-2.3.1.orig/exe/isql.c unixODBC-2.3.1/exe/isql.c
+--- unixODBC-2.3.1.orig/exe/isql.c 2011-09-15 12:57:14.000000000 -0400
++++ unixODBC-2.3.1/exe/isql.c 2013-03-19 13:27:09.907545641 -0400
+@@ -121,6 +121,7 @@
+ break;
+ case '3':
+ version3 = 1;
++ break;
+ case 'v':
+ bVerbose = 1;
+ break;
+@@ -611,8 +612,7 @@
+ {
+ if ( bVerbose ) DumpODBCLog( hEnv, hDbc, hStmt );
+ fprintf( stderr, "[ISQL]ERROR: Could not SQLNumResultCols\n" );
+- SQLFreeStmt( hStmt, SQL_DROP );
+- free(szSepLine);
++ break;
+ }
+
+ if ( cols > 0 )
diff --git a/unixODBC.spec b/unixODBC.spec
index d538c51..58f8a7d 100644
--- a/unixODBC.spec
+++ b/unixODBC.spec
@@ -1,7 +1,7 @@
Summary: A complete ODBC driver manager for Linux
Name: unixODBC
Version: 2.3.1
-Release: 3%{?dist}
+Release: 4%{?dist}
Group: System Environment/Libraries
URL: http://www.unixODBC.org/
# Programs are GPL, libraries are LGPL, except News Server library is GPL.
@@ -16,6 +16,7 @@ Patch1: depcomp.patch
Patch6: export-symbols.patch
Patch8: so-version-bump.patch
Patch9: keep-typedefs.patch
+Patch10: coverity-fixes.patch
Conflicts: iodbc
@@ -45,6 +46,7 @@ ODBC, you need to install this package.
%patch6 -p1
%patch8 -p1
%patch9 -p1
+%patch10 -p1
chmod 0644 Drivers/MiniSQL/*.c
chmod 0644 Drivers/nn/*.c
@@ -149,6 +151,10 @@ rm -rf $RPM_BUILD_ROOT
%postun -p /sbin/ldconfig
%changelog
+* Tue Mar 19 2013 Tom Lane <tgl at redhat.com> 2.3.1-4
+- Fix assorted small bugs found by Coverity
+Related: #760877
+
* Fri Feb 15 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.3.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
More information about the scm-commits
mailing list