Commit e78e02c
Pack200: enforce strict attribute layout parsing (apache#747)
* Pack200: enforce strict attribute layout parsing
The parser for the [Pack200 attribute layout definitions](https://docs.oracle.com/en/java/javase/11/docs/specs/pack-spec.html#attribute-layout-definitions) micro-language was previously overly permissive, allowing invalid layouts and masking archive corruption.
This change implements strict parsing in accordance with the [Java 11 specification](https://docs.oracle.com/en/java/javase/11/docs/specs/pack-spec.html) and removes duplication of the micro-language parsing logic between `pack200.NewAttributeBands` and `unpack200.NewAttributeBands`.
* fix: PMD failure
* fix: restore purpose of `lastPIntegral`
* fix: remove type parameters from Javadoc
This fails on JDK up to 11 and is yet another Javadoc quirk.
* fix: additional bracket in Javadoc
* fix: AttributeLayoutParser Javadoc
* fix: formatting
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix: Javadoc copy/paste
* fix: remove unused import
* fix: additional Javadoc
* fix: `checkAnyIntTag` error message
* fix: remove difference `AttributeLayoutElement`/`LayoutElement`
* feat: add tests with deeply nested layouts
* fix: Add nesting level limit
This change adds a limit to the nesting level of `layout_element`s (64). Since all standard attribute layouts have a nesting level lower than 3, the limit should be suitable for most purposes.
* fix: AttributeLayoutUtils Javadoc
* fix: invalid test assertions
* fix: checkstyle
* Replace `Range<Integer>` with `IntegerRange`
* Improve internal package Javadoc
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent defeeff commit e78e02c
14 files changed
Lines changed: 1279 additions & 558 deletions
File tree
- src
- changes
- main/java/org/apache/commons/compress/harmony
- archive/internal/nls
- internal
- pack200
- unpack200
- test/java/org/apache/commons/compress/harmony
- internal
- pack200
- unpack200
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
540 | 545 | | |
541 | 546 | | |
542 | 547 | | |
543 | | - | |
| 548 | + | |
| 549 | + | |
544 | 550 | | |
545 | 551 | | |
546 | 552 | | |
547 | 553 | | |
548 | 554 | | |
549 | 555 | | |
550 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
551 | 584 | | |
552 | 585 | | |
553 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
0 commit comments