DefaultSettingsBuilder: Dead Windows drive-relative path handling
Found in: maven-4.0.x branch
File: impl/maven-impl/src/main/java/org/apache/maven/impl/settings/DefaultSettingsBuilder.java (lines 131-137)
Severity: Medium
Description
The check for drive-relative Windows paths is always false on all platforms:
if (localRepository != null && !localRepository.isEmpty()) {
Path file = Paths.get(localRepository);
if (!file.isAbsolute() && file.toString().startsWith(File.separator)) {
effective = effective.withLocalRepository(file.toAbsolutePath().toString());
}
}
On Windows, a path starting with \ (e.g., \foo\bar) is already absolute (relative to the current drive root), so file.isAbsolute() returns true and the inner condition fails. On Unix (/ separator), any path starting with / is also absolute. This means the condition !file.isAbsolute() && file.toString().startsWith(File.separator) is always false, making the entire block dead code. The intended fix for drive-relative paths is never executed.
DefaultSettingsBuilder: Dead Windows drive-relative path handling
Found in: maven-4.0.x branch
File:
impl/maven-impl/src/main/java/org/apache/maven/impl/settings/DefaultSettingsBuilder.java(lines 131-137)Severity: Medium
Description
The check for drive-relative Windows paths is always false on all platforms:
On Windows, a path starting with
\(e.g.,\foo\bar) is already absolute (relative to the current drive root), sofile.isAbsolute()returns true and the inner condition fails. On Unix (/separator), any path starting with/is also absolute. This means the condition!file.isAbsolute() && file.toString().startsWith(File.separator)is always false, making the entire block dead code. The intended fix for drive-relative paths is never executed.