Skip to content

Commit 8373c58

Browse files
committed
xcf: Fix potential buffer overflow on corrupt or maliciously-crafted XCF file.
1 parent 7b6f9bc commit 8373c58

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

IMG_xcf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ do_layer_surface(SDL_Surface * surface, SDL_RWops * src, xcf_header * head, xcf_
638638
p16 = (Uint16 *) p8;
639639
p = (Uint32 *) p8;
640640
for (y = ty; y < ty + oy; y++) {
641+
if ((ty >= surface->h) || ((tx+ox) > surface->w)) {
642+
break;
643+
}
641644
row = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch + tx * 4);
642645
switch (hierarchy->bpp) {
643646
case 4:

0 commit comments

Comments
 (0)