mirror of
https://github.com/opnsense/src.git
synced 2026-02-18 18:20:26 -05:00
libjail: Guard against programmer error in jailparam_export()
If the caller didn't use jailparam_import() to fetch the parameter value, an attempt to export it will trigger a segfault. Make it a bit easier to figure out what's happening in this situation. PR: 276809 Reviewed by: jamie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43732 (cherry picked from commit dfabf3efaa795e657f3858b7e2d0b11f8a51ecb5)
This commit is contained in:
parent
3a90a44537
commit
5e21d7cd31
1 changed files with 6 additions and 0 deletions
|
|
@ -738,6 +738,12 @@ jailparam_export(struct jailparam *jp)
|
|||
int i, nval, ival;
|
||||
char valbuf[INET6_ADDRSTRLEN];
|
||||
|
||||
if (jp->jp_value == NULL) {
|
||||
snprintf(jail_errmsg, JAIL_ERRMSGLEN,
|
||||
"parameter %s was not imported", jp->jp_name);
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) {
|
||||
value = strdup(jp->jp_value);
|
||||
if (value == NULL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue