mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Merge pull request #12410 from Alcaro/master
rpng: Fix some memory corruption if processing broken input
This commit is contained in:
commit
90abd49892
@ -1035,7 +1035,9 @@ bool rpng_iterate_image(rpng_t *rpng)
|
|||||||
rpng->ihdr.interlace = buf[12];
|
rpng->ihdr.interlace = buf[12];
|
||||||
|
|
||||||
if ( rpng->ihdr.width == 0
|
if ( rpng->ihdr.width == 0
|
||||||
|| rpng->ihdr.height == 0)
|
|| rpng->ihdr.height == 0
|
||||||
|
/* ensure multiplications don't overflow and wrap around, that'd give buffer overflow crashes */
|
||||||
|
|| (uint64_t)rpng->ihdr.width*rpng->ihdr.height*sizeof(uint32_t) >= 0x80000000)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!png_process_ihdr(&rpng->ihdr))
|
if (!png_process_ihdr(&rpng->ihdr))
|
||||||
@ -1169,6 +1171,7 @@ error:
|
|||||||
if (rpng->process->stream)
|
if (rpng->process->stream)
|
||||||
rpng->process->stream_backend->stream_free(rpng->process->stream);
|
rpng->process->stream_backend->stream_free(rpng->process->stream);
|
||||||
free(rpng->process);
|
free(rpng->process);
|
||||||
|
rpng->process = NULL;
|
||||||
}
|
}
|
||||||
return IMAGE_PROCESS_ERROR;
|
return IMAGE_PROCESS_ERROR;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user