snprintf() always terminates output with \0

This commit is contained in:
Tomas Mraz 2016-11-15 16:05:44 +01:00
parent 4471e5419d
commit 6401c5b4ee

View File

@ -338,8 +338,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
errno = ENOMEM;
return NULL;
}
snprintf(new_line, new_line_len, "%s\n%s", gr1->line, gr2->line);
new_line[new_line_len] = '\0';
snprintf(new_line, new_line_len + 1, "%s\n%s", gr1->line, gr2->line);
/* Concatenate the 2 list of members */
for (i=0; NULL != gptr1->gr_mem[i]; i++);