Commit e50a61e
committed
fix(pdf): V4/AES-128 key length reads top-level /Length, not /CF subdict's
Reported by docscan (who vendored pdf_decryptor.zig and hit it integrating
blank-password PDF decryption). For V4/AESV2, qpdf orders the /CF crypt-filter
subdict — whose /Length 16 is key BYTES — before the top-level /Length 128 (key
BITS). The first-match /Length scan grabbed the nested 16 → divFloor(16,8)=2 →
clamped to 5 → a 40-bit key → wrong file key → garbage decrypt. Now a depth-aware
scan takes the brace-depth-1 /Length. RC4 (single /Length) and V5/AES-256 (UE key
path, no /Length-derived key) were unaffected; only V4/AESV2 was broken, and it
was undertested (suite covered RC4 + V5/R6, not V4 end-to-end).
TDD: added a V4/AESV2 inline-fixture regression test (CF /Length 16 ordered before
top-level /Length 128) asserting key_length==16 — confirmed RED (found 5) before
the fix, GREEN after. All 13 pdf_decryptor tests + full ./test pass.1 parent 53c9a49 commit e50a61e
1 file changed
Lines changed: 51 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
141 | 166 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 167 | | |
146 | 168 | | |
147 | 169 | | |
| |||
1101 | 1123 | | |
1102 | 1124 | | |
1103 | 1125 | | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
0 commit comments