[
https://issues.apache.org/jira/browse/TRAFODION-2725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16146688#comment-16146688
]
ASF GitHub Bot commented on TRAFODION-2725:
-------------------------------------------
GitHub user SuJinpei opened a pull request:
https://github.com/apache/incubator-trafodion/pull/1220
[TRAFODION-2725] SQL types are REAL, FLOAT, and DOUBLE. Some values are
inserted, a stack overflow occurs when SQLGetData is executed.
**_root cause:_** write stack variable out of range.
unsigned long ODBC::ConvertSQLToC(...., targetLength) {
...
CHAR cTmpBuf[132];
...
double_to_char (dTmp, FLT_DIG + 1, cTmpBuf, targetLength) // when
targetLength > 132, the stack will be broken.
...
}
**_fixed by:_**limit the max size to sizeof(cTmpBuf)
**_test result:_**run coast to check, no new issue introduced.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/SuJinpei/incubator-trafodion trafodion-2725
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-trafodion/pull/1220.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1220
----
commit 73548715fd95856d34724bb7c2f4b44e3c3b7f3d
Author: SuJinpei <[email protected]>
Date: 2017-08-25T07:45:19Z
fix TRAFODION-2725
commit b6513da5a82f9161457ae854a30cab2026b5c865
Author: SuJinpei <[email protected]>
Date: 2017-08-30T06:00:17Z
fix TRAFODION-2725
----
> SQL types are REAL, FLOAT, and DOUBLE. Some values are inserted, a stack
> overflow occurs when SQLGetData is executed.
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: TRAFODION-2725
> URL: https://issues.apache.org/jira/browse/TRAFODION-2725
> Project: Apache Trafodion
> Issue Type: Bug
> Components: client-odbc-windows
> Affects Versions: 2.2-incubating
> Reporter: 苏锦佩
> Fix For: 2.2-incubating
>
>
> The inserted value is -2.22507e-308, and the SQLGetData receive buffer is
> greater than 256,when the double column data is fetched, the program sends a
> crash.
> example:
> TCHAR tempbuf[256] = {0};
> SQLExecDirect(hstmt, (SQLTCHAR*)"CREATE TABLE TB_DOUBLE (ID INT, C DOUBLE
> PRECISION)", SQL_NTS);
> SQLExecDirect(hstmt, (SQLTCHAR*)"INSERT INTO TB_DOUBLE VALUES
> (1,-2.22507e-308)", SQL_NTS);
> SQLExecDirect(hstmt, (SQLTCHAR*)"SELECT * FROM TB_DOUBLE", SQL_NTS);
> SQLNumResultCols(hstmt, &numOfCols);
> SQLFetch(hstmt);
> for(i = 1; i <= numOfCols; i++){
> SQLGetData(hstmt,(SWORD)i,SQL_C_CHAR,tempbuf,sizeof(tempbuf),&len);
> }
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)