Skip to content

[GLUTEN-8534][VL] Fix allowing loops to iterate beyond end of array#8535

Merged
FelixYBW merged 1 commit intoapache:mainfrom
jkhaliqi:jk_cve_loop_ooo
Jan 17, 2025
Merged

[GLUTEN-8534][VL] Fix allowing loops to iterate beyond end of array#8535
FelixYBW merged 1 commit intoapache:mainfrom
jkhaliqi:jk_cve_loop_ooo

Conversation

@jkhaliqi
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Allowing loops to iterate beyond the end of an array
Since we know bytesValue2 is size 16 the length needs to also be 16 or less so we do not iterate before(beyond) the size of that bytesValue2 array

(Fixes: #8534)

@github-actions github-actions bot added the VELOX label Jan 14, 2025
@github-actions
Copy link
Copy Markdown

#8534

uint8_t bytesValue2[16]{};
for (int k = length - 1; k >= 0; k--) {
bytesValue2[length - 1 - k] = bytesValue[k];
if (length <= 16) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an assert instead.

@jkhaliqi jkhaliqi force-pushed the jk_cve_loop_ooo branch 2 times, most recently from 72dc1f9 to bada959 Compare January 15, 2025 22:01
uint8_t bytesValue[length];
memcpy(bytesValue, memoryAddress + offsets[pos] + wordoffset, length);
uint8_t bytesValue2[16]{};
assert(length <= 16);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkhaliqi jkhaliqi force-pushed the jk_cve_loop_ooo branch 4 times, most recently from 144bd4b to 2455558 Compare January 16, 2025 16:56
@FelixYBW FelixYBW merged commit d788a6f into apache:main Jan 17, 2025
baibaichen pushed a commit to baibaichen/gluten that referenced this pull request Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Allowing loops to iterate beyond the end of an array

2 participants