aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2024-02-04 02:22:09 +0000
committerMark Johnston <markj@FreeBSD.org>2024-02-11 15:14:59 +0000
commit5e21d7cd31194faf8c2bdda2bc60adf34eaa405a (patch)
treeea0fcf55d549079695df4ece3f7dedaba0581a18
parent3a90a4453750b12444e96d647d7c1203dc1cc9c5 (diff)
downloadsrc-5e21d7cd31194faf8c2bdda2bc60adf34eaa405a.tar.gz
src-5e21d7cd31194faf8c2bdda2bc60adf34eaa405a.zip
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)
-rw-r--r--lib/libjail/jail.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c
index 04fd6d3c4250..2af210ebb198 100644
--- a/lib/libjail/jail.c
+++ b/lib/libjail/jail.c
@@ -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)