Skip to content

Commit

Permalink
Merge pull request #230 from FirebirdSQL/229-abnormal-termination-in-…
Browse files Browse the repository at this point in the history
…sqlfetch

Issue#229: Fix NULL pointer dereference when binding column without i…
  • Loading branch information
irodushka authored Sep 26, 2024
2 parents 4584677 + 88c1941 commit d3abb24
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions ChangeLog_v3.0
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Abnormal termination in SQLFetch()
#229 by fdcastel

* OOAPI implemented
Related to this entire release
Expand Down
21 changes: 13 additions & 8 deletions OdbcConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) \
Expand Down Expand Up @@ -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 ) \
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion WriteBuildNo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d3abb24

Please sign in to comment.