Skip to content

Commit 7592194

Browse files
Ekaterina VergizovaRealCLanger
authored andcommitted
8296692: Improve String platform support
Reviewed-by: mbalao Backport-of: ed8643947e21263588cb6e9202efb3a30f450c4e
1 parent 3e10627 commit 7592194

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/jdk.management.agent/unix/classes/jdk/internal/agent/FileSystemImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
2929
import java.io.IOException;
3030

3131
/*
32-
* Solaris/Linux implementation of jdk.internal.agent.FileSystem
32+
* Linux implementation of jdk.internal.agent.FileSystem
3333
*/
3434
@SuppressWarnings("removal")
3535
public class FileSystemImpl extends FileSystem {
@@ -39,6 +39,10 @@ public boolean supportsFileSecurity(File f) throws IOException {
3939
}
4040

4141
public boolean isAccessUserOnly(File f) throws IOException {
42+
String path = f.getPath();
43+
if (path.indexOf(0) >= 0) {
44+
throw new IOException("illegal filename");
45+
}
4246
return isAccessUserOnly0(f.getPath());
4347
}
4448

src/jdk.management.agent/windows/classes/jdk/internal/agent/FileSystemImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,11 +35,18 @@
3535
public class FileSystemImpl extends FileSystem {
3636

3737
public boolean supportsFileSecurity(File f) throws IOException {
38+
String path = f.getAbsolutePath();
39+
if (path.indexOf(0) >= 0) {
40+
throw new IOException("illegal filename");
41+
}
3842
return isSecuritySupported0(f.getAbsolutePath());
3943
}
4044

4145
public boolean isAccessUserOnly(File f) throws IOException {
4246
String path = f.getAbsolutePath();
47+
if (path.indexOf(0) >= 0) {
48+
throw new IOException("illegal filename");
49+
}
4350
if (!isSecuritySupported0(path)) {
4451
throw new UnsupportedOperationException("File system does not support file security");
4552
}

0 commit comments

Comments
 (0)