From a3ac3c0e93e08ed396c908a09438156396c07a22 Mon Sep 17 00:00:00 2001 From: irodushka Date: Thu, 26 Sep 2024 16:14:38 +0300 Subject: [PATCH 1/3] Issue#229: Fix NULL pointer dereference when binding column without indicator buffer --- OdbcConvert.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/OdbcConvert.cpp b/OdbcConvert.cpp index a745a9df..1f5a8594 100644 --- a/OdbcConvert.cpp +++ b/OdbcConvert.cpp @@ -95,6 +95,9 @@ int init() inline void setIndicatorPtr(SQLLEN* ptr, SQLLEN value, DescRecord* rec) { + if (!ptr) + return; + if (rec->isIndicatorSqlDa) { *(short*)ptr = (short)value; @@ -1018,25 +1021,25 @@ ADRESS_FUNCTION OdbcConvert::getAdressFunction(DescRecord * from, DescRecord * t inline SQLPOINTER OdbcConvert::getAdressBindDataFrom(char * pointer) { - return (SQLPOINTER)(pointer + *bindOffsetPtrFrom); + return pointer ? (SQLPOINTER)(pointer + *bindOffsetPtrFrom) : NULL; } inline SQLLEN * OdbcConvert::getAdressBindIndFrom(char * pointer) { - return (SQLLEN *)(pointer + *bindOffsetPtrIndFrom); + return pointer ? (SQLLEN *)(pointer + *bindOffsetPtrIndFrom) : NULL; } inline SQLPOINTER OdbcConvert::getAdressBindDataTo(char * pointer) { - return (SQLPOINTER)(pointer + *bindOffsetPtrTo); + return pointer ? (SQLPOINTER)(pointer + *bindOffsetPtrTo) : NULL; } inline SQLLEN * OdbcConvert::getAdressBindIndTo(char * pointer) { - return (SQLLEN *)(pointer + *bindOffsetPtrIndTo); + return pointer ? (SQLLEN *)(pointer + *bindOffsetPtrIndTo) : NULL; } #define ODBCCONVERT_CHECKNULL(pointerTo) \ @@ -1081,10 +1084,11 @@ SQLLEN * OdbcConvert::getAdressBindIndTo(char * pointer) { \ if( checkIndicatorPtr( indicatorFrom, SQL_NULL_DATA, from ) ) \ { \ - setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \ + if ( indicatorTo ) \ + setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \ return SQL_SUCCESS; \ } \ - else \ + else if ( indicatorTo ) \ setIndicatorPtr( indicatorTo, 0, to ); \ } \ if ( !pointer ) \ @@ -1093,10 +1097,11 @@ SQLLEN * OdbcConvert::getAdressBindIndTo(char * pointer) #define ODBCCONVERT_CHECKNULL_SQLDA \ if( checkIndicatorPtr( indicatorFrom, SQL_NULL_DATA, from ) ) \ { \ - setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \ + if ( indicatorTo ) \ + setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \ return SQL_SUCCESS; \ } \ - else \ + else if ( indicatorTo ) \ setIndicatorPtr( indicatorTo, 0, to ); \ #define GET_LEN_FROM_OCTETLENGTHPTR \ From b4ab95e067fe469f72e20d6144001506622064a1 Mon Sep 17 00:00:00 2001 From: irodushka Date: Thu, 26 Sep 2024 16:23:27 +0300 Subject: [PATCH 2/3] Issue#229: Build version 11 -> 12 --- WriteBuildNo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WriteBuildNo.h b/WriteBuildNo.h index 4e985bf0..40a19402 100644 --- a/WriteBuildNo.h +++ b/WriteBuildNo.h @@ -4,4 +4,4 @@ // Note - there must be two tabs between BUILDNUM_VERSION and // the actual number, otherwise the makefile for linux will not // pick up the value. -#define BUILDNUM_VERSION 11 +#define BUILDNUM_VERSION 12 From 88c194149ceeb81549f8c65db0f85abcdb4f2971 Mon Sep 17 00:00:00 2001 From: irodushka Date: Thu, 26 Sep 2024 16:31:20 +0300 Subject: [PATCH 3/3] Issue#229: ChangeLog --- ChangeLog_v3.0 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog_v3.0 b/ChangeLog_v3.0 index 5d814166..80f160bd 100644 --- a/ChangeLog_v3.0 +++ b/ChangeLog_v3.0 @@ -1,3 +1,5 @@ + * Abnormal termination in SQLFetch() + #229 by fdcastel * OOAPI implemented Related to this entire release