Use strndup(3) instead of malloc + memcpy
This commit is contained in:
parent
2d23488dac
commit
5c8e56f615
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315746
@ -351,9 +351,8 @@ read_excludes_file(char *file)
|
||||
while ((buf = fgetln(fp, &len)) != NULL) {
|
||||
if (buf[len - 1] == '\n')
|
||||
len--;
|
||||
pattern = xmalloc(len + 1);
|
||||
memcpy(pattern, buf, len);
|
||||
pattern[len] = '\0';
|
||||
if ((pattern = strndup(buf, len)) == NULL)
|
||||
err(2, "xstrndup");
|
||||
push_excludes(pattern);
|
||||
}
|
||||
if (strcmp(file, "-") != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user