Skip to content

Commit b71b80f

Browse files
committed
tests: Use snprintf() instead of sprintf()
`man sprintf` suggests using snprintf() instead of sprintf()
1 parent f72ff0c commit b71b80f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/test-api-tagsOpen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ main (void)
276276
for (int i = 0; i < 6; i++)
277277
{
278278
char tagf_name_tmpl [] = "./api-tagsOpen-incomplete-program-author-%d.tags";
279-
char tagf_name [sizeof (tagf_name_tmpl)];
279+
char tagf_name [sizeof (tagf_name_tmpl) - 1];
280280
fprintf (stderr, "opening a tags file with incomplete PROGRAM_AUTHOR field [trimming level: %d]...", i);
281-
sprintf (tagf_name, tagf_name_tmpl, i);
281+
snprintf (tagf_name, sizeof (tagf_name), tagf_name_tmpl, i);
282282
t = tagsOpen (tagf_name, &info);
283283
if (t == NULL)
284284
{

0 commit comments

Comments
 (0)