Use strlcpy() instead of explicitly set \0 on the tail of the array.

This commit is contained in:
Xin LI 2009-06-23 23:32:24 +00:00
parent 431586a895
commit 884f7c03dd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=194796

View File

@ -142,8 +142,7 @@ add(const char *fmt)
badfmt(fmt);
if (!(tfu->fmt = malloc(p - savep + 1)))
err(1, NULL);
(void) strncpy(tfu->fmt, savep, p - savep);
tfu->fmt[p - savep] = '\0';
(void) strlcpy(tfu->fmt, savep, p - savep + 1);
escape(tfu->fmt);
p++;
}