Skip to content

Commit 598c8c8

Browse files
committed
GIF loader: check bad image separator, ensure left/top offset of image don't reach image margins (#122)
1 parent de45bbc commit 598c8c8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/fromgif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ gif_out_code(
275275
return;
276276
}
277277

278-
g->out[g->cur_x + g->cur_y * g->line_size] = g->codes[code].suffix;
278+
g->out[g->cur_x + g->cur_y * g->max_x] = g->codes[code].suffix;
279279
if (g->cur_x >= g->actual_width) {
280280
g->actual_width = g->cur_x + 1;
281281
}
@@ -433,7 +433,7 @@ gif_load_next(
433433
y = gif_get16le(s); /* Image Top Position (2 bytes) */
434434
w = gif_get16le(s); /* Image Width (2 bytes) */
435435
h = gif_get16le(s); /* Image Height (2 bytes) */
436-
if (((x + w) > (g->w)) || ((y + h) > (g->h))) {
436+
if (x >= g->w || y >= g->h || x + w > g->w || y + h > g->h) {
437437
sixel_helper_set_additional_message(
438438
"corrupt GIF (reason: bad Image Separator).");
439439
status = SIXEL_RUNTIME_ERROR;

0 commit comments

Comments
 (0)