mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 21:05:08 +00:00
- Fix logic error in swapoff case: follow same handling of p and
linelen in the swapon case. - Use strlcpy instead of strncpy. MFC after: 1 week
This commit is contained in:
parent
4abfd5bd93
commit
883b75538f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=360619
|
@ -548,8 +548,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
|
|||
ret = NULL;
|
||||
goto err;
|
||||
}
|
||||
strncpy(linebuf, p, linelen);
|
||||
linebuf[linelen - 1] = '\0';
|
||||
strlcpy(linebuf, p, linelen);
|
||||
errno = 0;
|
||||
ul = strtoul(linebuf, &p, 10);
|
||||
if (errno == 0) {
|
||||
|
@ -604,14 +603,13 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
|
|||
goto err;
|
||||
}
|
||||
p = fgetln(sfd, &linelen);
|
||||
if (p == NULL &&
|
||||
(linelen < 2 || linelen > sizeof(linebuf) - 1)) {
|
||||
if (p == NULL ||
|
||||
(linelen < 2 || linelen > sizeof(linebuf))) {
|
||||
warn("mdconfig (list) unexpected output");
|
||||
ret = NULL;
|
||||
goto err;
|
||||
}
|
||||
strncpy(linebuf, p, linelen);
|
||||
linebuf[linelen - 1] = '\0';
|
||||
strlcpy(linebuf, p, linelen);
|
||||
p = strchr(linebuf, ' ');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
|
|
Loading…
Reference in a new issue