Skip to content

Commit d3abb24

Browse files
authored
Merge pull request #230 from FirebirdSQL/229-abnormal-termination-in-sqlfetch
Issue#229: Fix NULL pointer dereference when binding column without i…
2 parents 4584677 + 88c1941 commit d3abb24

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

ChangeLog_v3.0

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Abnormal termination in SQLFetch()
2+
#229 by fdcastel
13

24
* OOAPI implemented
35
Related to this entire release

OdbcConvert.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ int init()
9595

9696
inline void setIndicatorPtr(SQLLEN* ptr, SQLLEN value, DescRecord* rec)
9797
{
98+
if (!ptr)
99+
return;
100+
98101
if (rec->isIndicatorSqlDa)
99102
{
100103
*(short*)ptr = (short)value;
@@ -1018,25 +1021,25 @@ ADRESS_FUNCTION OdbcConvert::getAdressFunction(DescRecord * from, DescRecord * t
10181021
inline
10191022
SQLPOINTER OdbcConvert::getAdressBindDataFrom(char * pointer)
10201023
{
1021-
return (SQLPOINTER)(pointer + *bindOffsetPtrFrom);
1024+
return pointer ? (SQLPOINTER)(pointer + *bindOffsetPtrFrom) : NULL;
10221025
}
10231026

10241027
inline
10251028
SQLLEN * OdbcConvert::getAdressBindIndFrom(char * pointer)
10261029
{
1027-
return (SQLLEN *)(pointer + *bindOffsetPtrIndFrom);
1030+
return pointer ? (SQLLEN *)(pointer + *bindOffsetPtrIndFrom) : NULL;
10281031
}
10291032

10301033
inline
10311034
SQLPOINTER OdbcConvert::getAdressBindDataTo(char * pointer)
10321035
{
1033-
return (SQLPOINTER)(pointer + *bindOffsetPtrTo);
1036+
return pointer ? (SQLPOINTER)(pointer + *bindOffsetPtrTo) : NULL;
10341037
}
10351038

10361039
inline
10371040
SQLLEN * OdbcConvert::getAdressBindIndTo(char * pointer)
10381041
{
1039-
return (SQLLEN *)(pointer + *bindOffsetPtrIndTo);
1042+
return pointer ? (SQLLEN *)(pointer + *bindOffsetPtrIndTo) : NULL;
10401043
}
10411044

10421045
#define ODBCCONVERT_CHECKNULL(pointerTo) \
@@ -1081,10 +1084,11 @@ SQLLEN * OdbcConvert::getAdressBindIndTo(char * pointer)
10811084
{ \
10821085
if( checkIndicatorPtr( indicatorFrom, SQL_NULL_DATA, from ) ) \
10831086
{ \
1084-
setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \
1087+
if ( indicatorTo ) \
1088+
setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \
10851089
return SQL_SUCCESS; \
10861090
} \
1087-
else \
1091+
else if ( indicatorTo ) \
10881092
setIndicatorPtr( indicatorTo, 0, to ); \
10891093
} \
10901094
if ( !pointer ) \
@@ -1093,10 +1097,11 @@ SQLLEN * OdbcConvert::getAdressBindIndTo(char * pointer)
10931097
#define ODBCCONVERT_CHECKNULL_SQLDA \
10941098
if( checkIndicatorPtr( indicatorFrom, SQL_NULL_DATA, from ) ) \
10951099
{ \
1096-
setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \
1100+
if ( indicatorTo ) \
1101+
setIndicatorPtr( indicatorTo, SQL_NULL_DATA, to ); \
10971102
return SQL_SUCCESS; \
10981103
} \
1099-
else \
1104+
else if ( indicatorTo ) \
11001105
setIndicatorPtr( indicatorTo, 0, to ); \
11011106

11021107
#define GET_LEN_FROM_OCTETLENGTHPTR \

WriteBuildNo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
// Note - there must be two tabs between BUILDNUM_VERSION and
55
// the actual number, otherwise the makefile for linux will not
66
// pick up the value.
7-
#define BUILDNUM_VERSION 11
7+
#define BUILDNUM_VERSION 12

0 commit comments

Comments
 (0)