Skip to content

Commit 07b3bf8

Browse files
committed
Replace sprintf with snprintf
In C99 7.19.6.5 sprintf, "If copying takes place between objects that overlap, the behavior is undefined". Replace sprintf with snprintf and provide a clear buffer size to ensure undefined behavior does not occur. And the sizeof(buff) + 1 includes the null terminator.
1 parent 2cfba0f commit 07b3bf8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/font-edit/twin-fedit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void draw_char(char_t *c)
338338
cairo_set_source_rgb(cr, 0, .5, .5);
339339

340340
cairo_move_to(cr, tx - 2, ty + 3);
341-
sprintf(buf, "%d", i);
341+
snprintf(buf, sizeof(buf) + 1, "%d", i);
342342
cairo_show_text(cr, buf);
343343
cairo_restore(cr);
344344
}

0 commit comments

Comments
 (0)