Commit 61c9bca
Fix memory exhaustion caused by circular references in PDF xref chains (#787)
* Fix memory exhaustion caused by circular references in PDF xref chains (#2)
* Initial plan
* Initial setup: Add crash file and reproducer script
Co-authored-by: k00ni <[email protected]>
* Fix infinite loop caused by circular xref references
Co-authored-by: k00ni <[email protected]>
* Add test case for circular xref reference fix
Co-authored-by: k00ni <[email protected]>
* Address review feedback: Add array<int> type hints and remove test
- Added array<int> type hints to $visitedOffsets parameters in PHPDoc comments
- Removed testCircularXrefReference test as requested by reviewer
- Removed reproducer.php file as requested
- Crash file memory-exhaustion-crash-f5d89649.txt remains permanently in samples/bugs/
Co-authored-by: k00ni <[email protected]>
* Remove crash file and add comprehensive tests for circular reference fix
- Removed memory-exhaustion-crash-f5d89649.txt as requested
- Added helper methods to expose protected functions for testing
- Added testGetXrefDataPreventsCircularReferences: Tests that visitedOffsets prevents infinite loops
- Added testDecodeXrefPassesVisitedOffsets: Tests that decodeXref correctly passes visitedOffsets
- Added testGetXrefDataTracksVisitedOffsets: Tests that offsets are tracked properly
- All tests use minimal PDF structures and don't rely on external crash file
Co-authored-by: k00ni <[email protected]>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: k00ni <[email protected]>
* Removed PHP-CS-Fixer issues
---------
Co-authored-by: Copilot <[email protected]>
Co-authored-by: k00ni <[email protected]>1 parent 6b52c6b commit 61c9bca
File tree
2 files changed
+128
-15
lines changed- src/Smalot/PdfParser/RawData
- tests/PHPUnit/Integration/RawData
2 files changed
+128
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
157 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | | - | |
| 164 | + | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| |||
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
222 | | - | |
| 223 | + | |
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| |||
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
235 | | - | |
236 | | - | |
237 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
243 | | - | |
| 245 | + | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
| |||
502 | 504 | | |
503 | 505 | | |
504 | 506 | | |
505 | | - | |
| 507 | + | |
506 | 508 | | |
507 | 509 | | |
508 | 510 | | |
| |||
862 | 864 | | |
863 | 865 | | |
864 | 866 | | |
865 | | - | |
866 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
867 | 870 | | |
868 | 871 | | |
869 | 872 | | |
870 | 873 | | |
871 | 874 | | |
872 | 875 | | |
873 | | - | |
| 876 | + | |
874 | 877 | | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
875 | 886 | | |
876 | 887 | | |
877 | 888 | | |
| |||
914 | 925 | | |
915 | 926 | | |
916 | 927 | | |
917 | | - | |
| 928 | + | |
918 | 929 | | |
919 | 930 | | |
920 | 931 | | |
| |||
923 | 934 | | |
924 | 935 | | |
925 | 936 | | |
926 | | - | |
| 937 | + | |
927 | 938 | | |
928 | 939 | | |
929 | 940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
51 | 75 | | |
52 | 76 | | |
53 | 77 | | |
| |||
213 | 237 | | |
214 | 238 | | |
215 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
216 | 318 | | |
0 commit comments