Don't copy and return a potentially unset buffer when jail_get fails.
This commit is contained in:
parent
c26c472cc8
commit
fba36ac4de
@ -94,11 +94,15 @@ jail_getname(int jid)
|
|||||||
jiov[5].iov_len = JAIL_ERRMSGLEN;
|
jiov[5].iov_len = JAIL_ERRMSGLEN;
|
||||||
jail_errmsg[0] = 0;
|
jail_errmsg[0] = 0;
|
||||||
jid = jail_get(jiov, 6, 0);
|
jid = jail_get(jiov, 6, 0);
|
||||||
if (jid < 0 && !jail_errmsg[0])
|
if (jid < 0) {
|
||||||
snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s",
|
if (!jail_errmsg[0])
|
||||||
strerror(errno));
|
snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s",
|
||||||
name = strdup(namebuf);
|
strerror(errno));
|
||||||
if (name == NULL)
|
return NULL;
|
||||||
strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
|
} else {
|
||||||
|
name = strdup(namebuf);
|
||||||
|
if (name == NULL)
|
||||||
|
strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user