Skip to content

Commit

Permalink
gif: Fix potential infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Oct 31, 2024
1 parent 980bd4c commit f177b5f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/image-gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ static void read_ext(twin_gif_t *gif)
{
uint8_t label;

read(gif->fd, &label, 1);
if (read(gif->fd, &label, 1) < 1)
return;
switch (label) {
case 0x01:
read_plain_text_ext(gif);
Expand Down Expand Up @@ -494,11 +495,11 @@ static int gif_get_frame(twin_gif_t *gif)
while (sep != ',') {
if (sep == ';')
return 0;
if (sep == '!')
read_ext(gif);
else
if (sep != '!')
return -1;
read_ext(gif);
if (read(gif->fd, &sep, 1) < 1)
return -1;
read(gif->fd, &sep, 1);
}
if (read_image(gif) == -1)
return -1;
Expand Down

0 comments on commit f177b5f

Please sign in to comment.