6736390: File TOCTOU deserialization vulnerability
Reviewed-by: hawtin
This commit is contained in:
parent
9b6c8a826f
commit
8358846d5f
@ -2064,11 +2064,12 @@ public class File
|
|||||||
private synchronized void readObject(java.io.ObjectInputStream s)
|
private synchronized void readObject(java.io.ObjectInputStream s)
|
||||||
throws IOException, ClassNotFoundException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
s.defaultReadObject();
|
ObjectInputStream.GetField fields = s.readFields();
|
||||||
|
String pathField = (String)fields.get("path", null);
|
||||||
char sep = s.readChar(); // read the previous separator char
|
char sep = s.readChar(); // read the previous separator char
|
||||||
if (sep != separatorChar)
|
if (sep != separatorChar)
|
||||||
this.path = this.path.replace(sep, separatorChar);
|
pathField = pathField.replace(sep, separatorChar);
|
||||||
this.path = fs.normalize(this.path);
|
this.path = fs.normalize(pathField);
|
||||||
this.prefixLength = fs.prefixLength(this.path);
|
this.prefixLength = fs.prefixLength(this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user