Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.17] Added test to verify the int overflow happen (backport #17353) #17356

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Mar 19, 2025

Release notes

Avoid possible integer overflow in string tokenization.

What does this PR do?

Use long instead of int type to keep the length of the first token.

The size limit validation requires to sum two integers, one with the length of the accumulated chars till now plus the next fragment head part. If any of the two sizes is close to the max integer it generates an overflow and could successfully fail the test

.

To fall in this case it's required that sizeLimit is bigger then 2^32 bytes (2GB) and data fragments without any line delimiter is pushed to the tokenizer with a total size close to 2^32 bytes.

Why is it important/What is the impact to the user?

Avoid to miss the notification of buffer full condition when buffered tokenizer is used with a size a limit bigger than 2GB.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs


This is an automatic backport of pull request #17353 done by [Mergify](https://mergify.com).

Use long instead of int type to keep the length of the first token.

The size limit validation requires to sum two integers, one with the length of the accumulated chars till now plus the next fragment head part. If any of the two sizes is close to the max integer it generates an overflow and could successfully fail the test https://github.com/elastic/logstash/blob/9c0e50faacc4700da3dc84a3ba729b84bff860a8/logstash-core/src/main/java/org/logstash/common/BufferedTokenizerExt.java#L123.

To fall in this case it's required that sizeLimit is bigger then 2^32 bytes (2GB) and data fragments without any line delimiter is pushed to the tokenizer with a total size close to 2^32 bytes.

(cherry picked from commit afde43f)
@mergify mergify bot added the backport label Mar 19, 2025
@mergify mergify bot assigned andsel Mar 19, 2025
Copy link

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @andsel

@andsel andsel merged commit e095a18 into 8.17 Mar 19, 2025
7 checks passed
@andsel andsel deleted the mergify/bp/8.17/pr-17353 branch March 19, 2025 16:26
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.

2 participants