mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-04 09:09:56 +00:00
Don't copy and return a potentially unset buffer when jail_get fails.
This commit is contained in:
parent
c26c472cc8
commit
fba36ac4de
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=210134
@ -94,11 +94,15 @@ jail_getname(int jid)
|
||||
jiov[5].iov_len = JAIL_ERRMSGLEN;
|
||||
jail_errmsg[0] = 0;
|
||||
jid = jail_get(jiov, 6, 0);
|
||||
if (jid < 0 && !jail_errmsg[0])
|
||||
snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s",
|
||||
strerror(errno));
|
||||
name = strdup(namebuf);
|
||||
if (name == NULL)
|
||||
strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
|
||||
if (jid < 0) {
|
||||
if (!jail_errmsg[0])
|
||||
snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s",
|
||||
strerror(errno));
|
||||
return NULL;
|
||||
} else {
|
||||
name = strdup(namebuf);
|
||||
if (name == NULL)
|
||||
strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user