This is an automated email from the ASF dual-hosted git repository.
jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 6b1e88b480 Fix integer overflow in DBF header when fields have large
length constraints
6b1e88b480 is described below
commit 6b1e88b4805ba52a82e6e8f4eae8a3e89df1b00c
Author: jsorel <[email protected]>
AuthorDate: Mon Aug 12 15:46:42 2024 +0200
Fix integer overflow in DBF header when fields have large length constraints
---
.../main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java
index 8c0bca0aa0..fd80fa55b3 100644
---
a/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java
+++
b/incubator/src/org.apache.sis.storage.shapefile/main/org/apache/sis/storage/shapefile/dbf/DBFHeader.java
@@ -82,7 +82,8 @@ public final class DBFHeader {
headerSize = 32 + FIELD_SIZE * fields.length + 1;
recordSize = 1; //record state tag
for (DBFField field : fields) {
- recordSize += field.fieldLength;
+ //ensure we do not overflow because of very large incorrect field
length.
+ recordSize = Math.addExact(recordSize, field.fieldLength);
}
}