mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
add size check to prevent further corruption in case of read offset
This commit is contained in:
@@ -109,6 +109,9 @@ public class MantleChunk {
|
||||
din.skipTo(end);
|
||||
TectonicPlate.addError();
|
||||
}
|
||||
if (din.count() != start + size) {
|
||||
throw new IOException("Chunk section read size mismatch!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,10 +99,9 @@ public interface Matter {
|
||||
}
|
||||
|
||||
static Matter read(File f) throws IOException {
|
||||
FileInputStream in = new FileInputStream(f);
|
||||
Matter m = read(in);
|
||||
in.close();
|
||||
return m;
|
||||
try (var in = new FileInputStream(f)) {
|
||||
return read(in);
|
||||
}
|
||||
}
|
||||
|
||||
static Matter read(InputStream in) throws IOException {
|
||||
@@ -165,6 +164,10 @@ public interface Matter {
|
||||
}
|
||||
din.skipTo(end);
|
||||
}
|
||||
|
||||
if (din.count() != start + size) {
|
||||
throw new IOException("Matter slice read size mismatch!");
|
||||
}
|
||||
}
|
||||
|
||||
return matter;
|
||||
|
||||
Reference in New Issue
Block a user