9
0
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:
Julian Krings
2025-08-24 17:21:21 +02:00
parent 29390c5e0a
commit 4702534f9c
2 changed files with 10 additions and 4 deletions

View File

@@ -109,6 +109,9 @@ public class MantleChunk {
din.skipTo(end); din.skipTo(end);
TectonicPlate.addError(); TectonicPlate.addError();
} }
if (din.count() != start + size) {
throw new IOException("Chunk section read size mismatch!");
}
} }
} }

View File

@@ -99,10 +99,9 @@ public interface Matter {
} }
static Matter read(File f) throws IOException { static Matter read(File f) throws IOException {
FileInputStream in = new FileInputStream(f); try (var in = new FileInputStream(f)) {
Matter m = read(in); return read(in);
in.close(); }
return m;
} }
static Matter read(InputStream in) throws IOException { static Matter read(InputStream in) throws IOException {
@@ -165,6 +164,10 @@ public interface Matter {
} }
din.skipTo(end); din.skipTo(end);
} }
if (din.count() != start + size) {
throw new IOException("Matter slice read size mismatch!");
}
} }
return matter; return matter;