Skip to content

Commit

Permalink
libjail: Guard against programmer error in jailparam_export()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markjdb committed Feb 4, 2024
1 parent 064fa62 commit dfabf3e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/libjail/jail.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,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)
Expand Down

0 comments on commit dfabf3e

Please sign in to comment.