Commit d92d943
committed
ORC-2191: Reject overflowing PostScript tail lengths in ReaderImpl
### What changes were proposed in this pull request?
This PR validates the PostScript tail lengths in `ReaderImpl.extractFileTail` before they are cast
from `long` to `int`, throwing `FileFormatException` when `footerLength`, `metadataLength`,
`stripeStatisticsLength`, or their sum is negative or exceeds the file length / `Integer.MAX_VALUE`.
It is the Java counterpart of the C++ overflow checks in ORC-2167.
### Why are the changes needed?
These fields are protobuf `uint64` read as Java `long`. A malformed value near `UINT64_MAX` or above
2GB would truncate/overflow on the `int` cast into a bogus offset or allocation size instead of a
clear error. Per the ORC threat model this is a fail-fast robustness fix, not a CVE.
### How was this patch tested?
Added `TestReaderImpl.testMalformedTailLengthOverflow`, which crafts files with tail lengths of
`2^31`, `2^32`, and `UINT64_MAX` and asserts `OrcFile.createReader` throws `FileFormatException`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Fable 5
Closes #2672 from dongjoon-hyun/ORC-2191.
Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>1 parent 6015de5 commit d92d943
2 files changed
Lines changed: 88 additions & 5 deletions
File tree
- java/core/src
- java/org/apache/orc/impl
- test/org/apache/orc/impl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
857 | | - | |
858 | | - | |
859 | | - | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
860 | 878 | | |
861 | 879 | | |
862 | | - | |
863 | | - | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
864 | 889 | | |
865 | 890 | | |
866 | 891 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
175 | 233 | | |
176 | 234 | | |
177 | 235 | | |
| |||
0 commit comments