Skip to content

Commit

Permalink
font-edit: Fix potential overflow
Browse files Browse the repository at this point in the history
'snprintf' output between 2 and 11 bytes into a destination of size 10.
  • Loading branch information
jserv committed Aug 7, 2024
1 parent a1ba2eb commit 45c92b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/font-edit/twin-fedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static void draw_char(char_t *c)

for (cmd = c->cmd, i = 0; cmd; cmd = cmd->next, i++) {
double tx, ty;
char buf[10];
char buf[11];

if (cmd->op == op_curve) {
tx = cmd->pt[2].x;
Expand All @@ -338,7 +338,7 @@ static void draw_char(char_t *c)
cairo_set_source_rgb(cr, 0, .5, .5);

cairo_move_to(cr, tx - 2, ty + 3);
snprintf(buf, sizeof(buf) + 1, "%d", i);
snprintf(buf, sizeof(buf), "%d", i);
cairo_show_text(cr, buf);
cairo_restore(cr);
}
Expand Down

0 comments on commit 45c92b1

Please sign in to comment.