Skip to content

Commit

Permalink
XCF: check if there's sufficient data in the stream before allocating
Browse files Browse the repository at this point in the history
An XCF file could lie about the size of a string it contains. Perform a
check if there is enough of data in the stream before trying to
allocate the advertised size.
  • Loading branch information
janisozaur committed Sep 28, 2018
1 parent b8a008d commit 98e9457
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion IMG_xcf.c
Expand Up @@ -225,7 +225,8 @@ static char * read_string (SDL_RWops * src) {
char * data;

tmp = SDL_ReadBE32 (src);
if (tmp > 0) {
Sint64 remaining = SDL_RWsize(src) - SDL_RWtell(src);
if (tmp > 0 && tmp < remaining) {
data = (char *) SDL_malloc (sizeof (char) * tmp);
SDL_RWread (src, data, tmp, 1);
}
Expand Down

0 comments on commit 98e9457

Please sign in to comment.