Jiyoung Yoo has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/25079


Change subject: IMPALA-15532: Incorrect result in Instr() function when start 
position overflows 32-bit integer
......................................................................

IMPALA-15532: Incorrect result in Instr() function when start position 
overflows 32-bit integer

In the Instr() string function, passing a 64-bit integer as the 'position'
argument could cause integer overflow when implicitly converted to a
32-bit integer type. As a result, when the start position exceeded the
string bounds, it wrapped around and returned an incorrect non-zero index
instead of returning '0' (not found).

This patch fixes the issue by adding an early boundary check against
the string length using 64-bit comparisons before entering the search logic.
If the start position exceeds the positive or negative length of the string,
StringFunctions::Instr() immediately returns 0.

Testing:
- Added unit tests in expr-test

Change-Id: Ie023f75612b8db3ed2c73ff4760583e32dfe77c0
---
M be/src/exprs/expr-test.cc
M be/src/exprs/string-functions-ir.cc
2 files changed, 12 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/79/25079/1
--
To view, visit http://gerrit.cloudera.org:8080/25079
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie023f75612b8db3ed2c73ff4760583e32dfe77c0
Gerrit-Change-Number: 25079
Gerrit-PatchSet: 1
Gerrit-Owner: Jiyoung Yoo <[email protected]>

Reply via email to