Skip to content

GH-1246: validate decimal byte length before writing in setBigEndian#1247

Open
Arawoof06 wants to merge 1 commit into
apache:mainfrom
Arawoof06:decimal-setbigendian-length-check
Open

GH-1246: validate decimal byte length before writing in setBigEndian#1247
Arawoof06 wants to merge 1 commit into
apache:mainfrom
Arawoof06:decimal-setbigendian-length-check

Conversation

@Arawoof06

Copy link
Copy Markdown
Contributor

What's Changed

setBigEndian(int, byte[]) on DecimalVector and Decimal256Vector byte-swaps the value into the fixed-width slot with unchecked MemoryUtil writes and only checks the length afterwards, so a byte array longer than the type width overruns the slot into adjacent off-heap memory before the IllegalArgumentException fires. setBigEndianSafe(int, long, ArrowBuf, int) does the same write with no length check at all. This moves the length check ahead of the write and adds it to the safe variant, so oversized input is rejected before any memory is touched; valid lengths are unaffected.

Closes #1246.

@github-actions

Copy link
Copy Markdown

Thank you for opening a pull request!

Please label the PR with one or more of:

  • bug-fix
  • chore
  • dependencies
  • documentation
  • enhancement

Also, add the 'breaking-change' label if appropriate.

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DecimalVector.setBigEndian writes oversized value before validating length

1 participant