File tree Expand file tree Collapse file tree
src/main/java/org/apache/commons/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -994,18 +994,16 @@ public static String getName(final String fileName) {
994994 }
995995
996996 /**
997- * Check the input for null bytes, a sign of unsanitized data being passed to to file level functions.
997+ * Checks the input for null bytes, a sign of unsanitized data being passed to to file level functions.
998998 *
999999 * This may be used for poison byte attacks.
1000+ *
10001001 * @param path the path to check
10011002 */
10021003 private static void requireNonNullChars (final String path ) {
1003- final int len = path .length ();
1004- for (int i = 0 ; i < len ; i ++) {
1005- if (path .charAt (i ) == 0 ) {
1006- throw new IllegalArgumentException ("Null byte present in file/path name. There are no " +
1007- "known legitimate use cases for such data, but several injection attacks may use it" );
1008- }
1004+ if (path .indexOf (0 ) >= 0 ) {
1005+ throw new IllegalArgumentException ("Null byte present in file/path name. There are no "
1006+ + "known legitimate use cases for such data, but several injection attacks may use it" );
10091007 }
10101008 }
10111009
You can’t perform that action at this time.
0 commit comments