You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "arthurscchan (via GitHub)" <gi...@apache.org> on 2023/12/04 22:22:07 UTC

[PR] LANG-1721: Fix wrong number check that cause StringIndexOutOfBoundsException [commons-lang]

arthurscchan opened a new pull request, #1140:
URL: https://github.com/apache/commons-lang/pull/1140

   `NumberUtils.createNumber(String)` method implements lots of number checks to ensure the provided string is indeed a number. But there is a wrong conditional checking in the code, that could result in unexpected StringIndexOutOfBoundsException if a specially crafted input is provided. This PR fixes the problem by changing the conditional check criterion. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] LANG-1721: Fix wrong number check that cause StringIndexOutOfBoundsException [commons-lang]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #1140:
URL: https://github.com/apache/commons-lang/pull/1140


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] LANG-1721: Fix wrong number check that cause StringIndexOutOfBoundsException [commons-lang]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #1140:
URL: https://github.com/apache/commons-lang/pull/1140#discussion_r1414621900


##########
src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java:
##########
@@ -1743,4 +1743,9 @@ public void testToShortStringI() {
         assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String, short) 1 failed");
         assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String, short) 2 failed");
     }
+
+    @Test
+    public void testInvalidNumber() {
+        NumberUtils.createNumber("E123e.3");

Review Comment:
   This test does not assert anything. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] LANG-1721: Fix wrong number check that cause StringIndexOutOfBoundsException [commons-lang]

Posted by "arthurscchan (via GitHub)" <gi...@apache.org>.
arthurscchan commented on code in PR #1140:
URL: https://github.com/apache/commons-lang/pull/1140#discussion_r1417126384


##########
src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java:
##########
@@ -1743,4 +1743,9 @@ public void testToShortStringI() {
         assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String, short) 1 failed");
         assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String, short) 2 failed");
     }
+
+    @Test
+    public void testInvalidNumber() {
+        NumberUtils.createNumber("E123e.3");

Review Comment:
   Fixed in https://github.com/apache/commons-lang/pull/1140/commits/df3ea0ebfab96fc97aab3224993e7b29e5b08720.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] LANG-1721: Fix wrong number check that cause StringIndexOutOfBoundsException [commons-lang]

Posted by "arthurscchan (via GitHub)" <gi...@apache.org>.
arthurscchan commented on code in PR #1140:
URL: https://github.com/apache/commons-lang/pull/1140#discussion_r1414634154


##########
src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java:
##########
@@ -1743,4 +1743,9 @@ public void testToShortStringI() {
         assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String, short) 1 failed");
         assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String, short) 2 failed");
     }
+
+    @Test
+    public void testInvalidNumber() {
+        NumberUtils.createNumber("E123e.3");

Review Comment:
   Sorry for missing that. That's the bad thing to code in the night. Have fixed it now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org