Skip to content

Commit f51374b

Browse files
committed
Add validation for file names of non-directories
1 parent 7468154 commit f51374b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

io/src/main/java/io/smallrye/common/io/archive/ArchiveBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,9 @@ private void checkNoActiveEntry() {
14261426
*/
14271427
private CdEntry initEntry(String name, int method, boolean zip64,
14281428
FileAttribute<?>[] attrs, int fileType) throws IOException {
1429+
if (fileType != S_IFDIR && name.endsWith("/")) {
1430+
throw new IllegalArgumentException("Non-directory entry name must not end with '/': " + name);
1431+
}
14291432
CdEntry entry = new CdEntry();
14301433
entry.fileName = name.getBytes(StandardCharsets.UTF_8);
14311434
entry.method = method;

0 commit comments

Comments
 (0)