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

CODEC-315: Fix possible IndexOutOfBoundException thrown by PhoneticEngine.encode method #223

Merged
merged 1 commit into from
Nov 25, 2023

Conversation

arthurscchan
Copy link
Contributor

@arthurscchan arthurscchan commented Nov 23, 2023

This fixes possible StringIndexOutOfBoundsException and ArrayIndexOutOfBoundsException in src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java thrown by PhoneticEngine.encode() when the provided string only contains one of the name prefix of the chosen NameType or only contain single quotation character.

This PR fixes the parameter for the split method and adds a conditional check to ensure only strings and arrays are not empty before processing.

We found this bug using fuzzing by way of OSS-Fuzz. It is reported at https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64376 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64395.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

@arthurscchan
Thank you for your PR.
Please see my comments.

@garydgregory
Copy link
Member

@arthurscchan
Please use a better description in PRs and JIRA: Specify the class and method where the exception occurs.

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
@arthurscchan arthurscchan changed the title CODEC-315: Fix possible IndexOutOfBoundException CODEC-315: Fix possible IndexOutOfBoundException thrown by PhoneticEngine.encode method Nov 24, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (44e4c4d) 92.27% compared to head (ee02460) 92.27%.
Report is 2 commits behind head on master.

Files Patch % Lines
...ache/commons/codec/language/bm/PhoneticEngine.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #223   +/-   ##
=========================================
  Coverage     92.27%   92.27%           
- Complexity     1742     1743    +1     
=========================================
  Files            67       67           
  Lines          4584     4585    +1     
  Branches        709      710    +1     
=========================================
+ Hits           4230     4231    +1     
  Misses          242      242           
  Partials        112      112           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@garydgregory garydgregory merged commit 1f908b2 into apache:master Nov 25, 2023
8 checks passed
asfgit pushed a commit that referenced this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants