[ 
https://issues.apache.org/jira/browse/ASTERIXDB-2949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ali Alsuliman updated ASTERIXDB-2949:
-------------------------------------
    Description: 
SUBSTR function may produce a malformed string. SUBSTR function uses a string 
builder to construct the output substring. Before constructing the string, it 
gives an estimated length of the output substring to the string builder and 
then starts writing out the substring data to the builder buffer. If the actual 
data written exceeds the estimated length by an amount that requires the 
builder buffer to make more space to encode the actual length and shift the 
substring content, the resulting content gets malformed which might lead to 
failures up in the stack.

Also, for the function call SUBSTR(input_string, 0, num_chars_to_substring) 
with start offset = 0, SUBSTR always estimates the length to be 0-127 which 
means if the characters written go beyond 127, it will encounter the issue 
described above.

  was:SUBSTR function may produce a malformed string. SUBSTR function uses a 
string builder to construct the output substring. Before constructing the 
string, it gives an estimated length of the output substring to the string 
builder, and then starts writing out the substring data to the builder buffer. 
If the actual data written exceeds the estimated length by an amount that 
requires the builder buffer to make more space to encode the actual length and 
shift the substring content, the resulting content gets malformed which might 
lead to failures up in the stack.


> SUBSTR function may produce malformed string
> --------------------------------------------
>
>                 Key: ASTERIXDB-2949
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-2949
>             Project: Apache AsterixDB
>          Issue Type: Bug
>          Components: FUN - Functions, RT - Runtime
>    Affects Versions: 0.9.3
>            Reporter: Ali Alsuliman
>            Assignee: Ali Alsuliman
>            Priority: Major
>             Fix For: 0.9.8
>
>
> SUBSTR function may produce a malformed string. SUBSTR function uses a string 
> builder to construct the output substring. Before constructing the string, it 
> gives an estimated length of the output substring to the string builder and 
> then starts writing out the substring data to the builder buffer. If the 
> actual data written exceeds the estimated length by an amount that requires 
> the builder buffer to make more space to encode the actual length and shift 
> the substring content, the resulting content gets malformed which might lead 
> to failures up in the stack.
> Also, for the function call SUBSTR(input_string, 0, num_chars_to_substring) 
> with start offset = 0, SUBSTR always estimates the length to be 0-127 which 
> means if the characters written go beyond 127, it will encounter the issue 
> described above.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to