Repository navigation
Commit 2124a26
committed
PluginTARGA: bound RLE decode by image rows (CVE-2024-28581)
loadRLE's per-packet dib_end check assumes a flat address model, but
pixel rows wrap at line_size while the image only has height rows. An
over-long RLE packet whose flat span fits dib_end can still wrap past
the last row, overflowing the heap in _assignPixel (WRITE, all depths).
Stop the decode with a corruption notice once pixels run past the last
row; the check sits at the top of the pixel loop so packets ending
exactly on the last pixel still exit cleanly.
Also harden the same path: load 16/32-bit cache pixels with memcpy
(the RLE byte cache is file-offset aligned, not 2/4-aligned; UBSan
misaligned-load on crafted and valid files), and zero-fill short
IOCache refills at EOF so stale heap bytes never surface in pixels.
RED (ASan+UBSan, pre-fix) -> GREEN (post-fix) verified with
Ruanxingzhi/vul-report freeimage-r1909 cases 10024/10412/10470 plus a
guard-isolating crafted TGA; valid 8/16/24/32-bit RLE TGAs still
decode pixel-identically.
AI assistance disclosure: this patch was authored with AI assistance
(agentic coding CLI) and verified with AddressSanitizer/UBSan
red/green runs before submission.1 parent 8fea9cd commit 2124a26
1 file changed
Lines changed: 46 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
232 | 244 | | |
233 | 245 | | |
234 | 246 | | |
235 | 247 | | |
236 | | - | |
237 | | - | |
| 248 | + | |
238 | 249 | | |
239 | 250 | | |
240 | 251 | | |
| |||
243 | 254 | | |
244 | 255 | | |
245 | 256 | | |
246 | | - | |
| 257 | + | |
247 | 258 | | |
248 | 259 | | |
249 | 260 | | |
250 | | - | |
| 261 | + | |
251 | 262 | | |
252 | 263 | | |
253 | 264 | | |
| |||
258 | 269 | | |
259 | 270 | | |
260 | 271 | | |
261 | | - | |
262 | | - | |
| 272 | + | |
263 | 273 | | |
264 | 274 | | |
265 | 275 | | |
| |||
524 | 534 | | |
525 | 535 | | |
526 | 536 | | |
527 | | - | |
| 537 | + | |
528 | 538 | | |
529 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
530 | 544 | | |
531 | 545 | | |
532 | 546 | | |
| |||
558 | 572 | | |
559 | 573 | | |
560 | 574 | | |
561 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
562 | 581 | | |
563 | 582 | | |
564 | 583 | | |
| |||
640 | 659 | | |
641 | 660 | | |
642 | 661 | | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
643 | 674 | | |
644 | 675 | | |
645 | 676 | | |
| |||
655 | 686 | | |
656 | 687 | | |
657 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
658 | 695 | | |
659 | 696 | | |
660 | 697 | | |
| |||
0 commit comments