[ https://issues.apache.org/jira/browse/TRAFODION-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15285914#comment-15285914 ]
ASF GitHub Bot commented on TRAFODION-1853: ------------------------------------------- GitHub user ryzuo opened a pull request: https://github.com/apache/incubator-trafodion/pull/485 [TRAFODION-1853] Fix overflow of long type bit wise shifting in T4 LogicalByteArray Both extractLong methods of LogicalByteArray and Bytes classes are using bit wise shifting to extract the long value from byte array, but larger then 32 bit wise shifting will overflow. Change to use java.nio.ByteBuffer to construct and convert the long value from the source byte array. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ryzuo/incubator-trafodion jira1853 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-trafodion/pull/485.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 #485 ---- commit 184e47ebacd1d7d049e8f9e6fda43069a3d8fda4 Author: ryzuo <joshuamur...@gmail.com> Date: 2015-11-03T09:48:30Z Add initialization of some statement members. commit f706cadb05bc0fe58d91b2831181b92b75513a5e Author: ryzuo <joshuamur...@gmail.com> Date: 2016-05-06T07:19:34Z Memory and Statement management cleanup commit 780b3bbe0f8a4181c6a044f97a7ac3e400328c8f Author: ryzuo <joshuamur...@gmail.com> Date: 2015-11-16T04:13:18Z T2 Rowsets Implementation. 1. Fixed double free of sqlWarningOrError. 2. Deleted some unsed functions and comments. 3. Changed some function return/exit statements to use the consistent macro definition(which has debugging and error handling). commit 2c4b774bc37d0bcb7e36674575d3de1739b929eb Author: ryzuo <joshuamur...@gmail.com> Date: 2015-11-23T08:16:20Z Some memory management update in CSrvrStmt.cpp Updated some memory management code of the new Rowsets code, like wrapped new/delete operations into the common used macro definition in Debug.h, align with original T2 code. commit bfd5a391ad8d7b900dd75d46b74d9ee9aa1cb5ed Author: ryzuo <joshuamur...@gmail.com> Date: 2016-05-16T05:38:01Z Fix JIRA1853 Use ByteBuffer to construct and convert the long value from the source byte array. ---- > Bitwise shifting overflows when extracting long value from byte buffer in > JDBC T4 driver. > ----------------------------------------------------------------------------------------- > > Key: TRAFODION-1853 > URL: https://issues.apache.org/jira/browse/TRAFODION-1853 > Project: Apache Trafodion > Issue Type: Bug > Components: client-jdbc-t4 > Reporter: RuoYu Zuo > Assignee: RuoYu Zuo > Priority: Critical > > There's overflow been found in method extractLong() of class > LogicalByteArray, see code below: > long extractLong() { > long value; > if (swap) { > value = ((array[loc]) & 0x00000000000000ffL) | ((array[loc + 1] > << 8) & 0x000000000000ff00L) > | ((array[loc + 2] << 16) & 0x0000000000ff0000L) | > ((array[loc + 3] << 24) & 0x00000000ff000000L) > | ((array[loc + 4] << 32) & 0x000000ff00000000L) | > ((array[loc + 5] << 40) & 0x0000ff0000000000L) > | ((array[loc + 6] << 48) & 0x00ff000000000000L) | > ((array[loc + 7] << 56) & 0xff00000000000000L); > } else { > value = ((array[loc + 7]) & 0x00000000000000ffL) | ((array[loc + > 6] << 8) & 0x000000000000ff00L) > | ((array[loc + 5] << 16) & 0x0000000000ff0000L) | > ((array[loc + 4] << 24) & 0x00000000ff000000L) > | ((array[loc + 3] << 32) & 0x000000ff00000000L) | > ((array[loc + 2] << 40) & 0x0000ff0000000000L) > | ((array[loc + 1] << 48) & 0x00ff000000000000L) | > ((array[loc] << 56) & 0xff00000000000000L); > } > loc += 8; > return value; > } > By default, the bitwise shifting is based on 4 byte int, thus << 32 and >> 32 > is the maximum bits of shifting allowed, larger than this causes overflows. > In this case, the long value extracted by this method will never be correct > from 5th byte to 8th byte. -- This message was sent by Atlassian JIRA (v6.3.4#6332)