apache-commons-io/CVE-2021-29425-4.patch
2021-05-08 15:54:59 +08:00

41 lines
1.3 KiB
Diff

From 0842e1f60a1ca36c8db76a00c6001a38174de21b Mon Sep 17 00:00:00 2001
From: Stefan Bodewig <stefan.bodewig@innoq.com>
Date: Thu, 17 May 2018 21:04:34 +0200
Subject: [PATCH 4/4] remove IPv4 checks that are unnnecessary due to matching
regex
---
.../java/org/apache/commons/io/FilenameUtils.java | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/FilenameUtils.java b/src/main/java/org/apache/commons/io/FilenameUtils.java
index b93476bb..5da8f786 100644
--- a/src/main/java/org/apache/commons/io/FilenameUtils.java
+++ b/src/main/java/org/apache/commons/io/FilenameUtils.java
@@ -1490,20 +1490,9 @@ public class FilenameUtils {
}
// verify that address subgroups are legal
- for (int i = 1; i < 5; i++) {
+ for (int i = 1; i <= 4; i++) {
String ipSegment = m.group(i);
- if (ipSegment == null || ipSegment.length() == 0) {
- return false;
- }
-
- int iIpSegment = 0;
-
- try {
- iIpSegment = Integer.parseInt(ipSegment);
- } catch(NumberFormatException e) {
- return false;
- }
-
+ int iIpSegment = Integer.parseInt(ipSegment);
if (iIpSegment > IPV4_MAX_OCTET_VALUE) {
return false;
}
--
2.23.0