StringIndexOutOfBoundsException in HelpFormatter.findWrapPos
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libcommons-cli-java (Ubuntu) |
Fix Released
|
High
|
James Page | ||
Precise |
Won't Fix
|
High
|
James Page |
Bug Description
This bug has been fixed upstream in version 1.3 Could you look at backporting this fix or updating to the latest version?
https:/
"You should be able to get it to throw with a call like this:
findWrapPos( "hello", 3, 0 ); // should return -1
The exception gets thrown whenever the passed-in string does not contain any spaces, tabs, or newlines. It looks like line 914 was also expecting line 908 to have a <.
Also, I think there are other bugs. In this call:
findWrapPos( "helloooo\
we want it to short circuit and return the first newline if there is one in the substring starting at 7 with width 6 ("o\noo\ng"), and so it should return the index of the first '\n', which is 8. However, on lines 876 and 877, it's doing "pos <= width", instead of "pos <= startPos+width", so it won't return, and it will end up (incorrectly, I think) returning the index of the second newline's position. And once you fix lines 876 and 877, it's going to return 9 instead of 8, which I think is incorrect. The other return statements return pos, not pos+1, and I think line 879 should do the same."
Related branches
tags: | added: rls-mgr-p-tracking |
Changed in libcommons-cli-java (Ubuntu Precise): | |
milestone: | ubuntu-12.04-beta-2 → ubuntu-12.04 |
Changed in libcommons-cli-java (Ubuntu Precise): | |
milestone: | ubuntu-12.04 → ubuntu-12.04.1 |
Changed in libcommons-cli-java (Ubuntu): | |
milestone: | ubuntu-12.04 → quantal-alpha-1 |
Changed in libcommons-cli-java (Ubuntu Precise): | |
assignee: | Ubuntu Server Team (ubuntu-server) → James Page (james-page) |
Changed in libcommons-cli-java (Ubuntu): | |
assignee: | Ubuntu Server Team (ubuntu-server) → James Page (james-page) |
Changed in libcommons-cli-java (Ubuntu): | |
milestone: | quantal-alpha-1 → quantal-alpha-2 |
Changed in libcommons-cli-java (Ubuntu Precise): | |
status: | Incomplete → Won't Fix |
Andrew, thanks for the report!
Patch looks pretty minimal and its an upstream critical bug. This should definitely be fixed before precise releases.