From b81422ef7f7331fd7d6e7b42cf659356587cdcd3 Mon Sep 17 00:00:00 2001 From: Jamie Gritton Date: Wed, 27 Oct 2010 21:01:53 +0000 Subject: [PATCH] Find a jail's type as part of jailparam_init rather than waiting until it's absolutely necessary. MFC after: 1 week --- lib/libjail/jail.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c index 1be8358d85ba..99bd9709462e 100644 --- a/lib/libjail/jail.c +++ b/lib/libjail/jail.c @@ -250,10 +250,6 @@ jailparam_all(struct jailparam **jpp) } if (jailparam_init(jp + njp, buf + sizeof(SJPARAM)) < 0) goto error; - if (jailparam_type(jp + njp) < 0) { - njp++; - goto error; - } mib1[1] = 2; } jp = realloc(jp, njp * sizeof(*jp)); @@ -279,6 +275,10 @@ jailparam_init(struct jailparam *jp, const char *name) strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN); return (-1); } + if (jailparam_type(jp) < 0) { + jailparam_free(jp, 1); + return (-1); + } return (0); } @@ -293,8 +293,6 @@ jailparam_import(struct jailparam *jp, const char *value) const char *avalue; int i, nval, fw; - if (!jp->jp_ctltype && jailparam_type(jp) < 0) - return (-1); if (value == NULL) return (0); if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) { @@ -563,8 +561,6 @@ jailparam_get(struct jailparam *jp, unsigned njp, int flags) jp_lastjid = jp_jid = jp_name = NULL; arrays = 0; for (ai = j = 0; j < njp; j++) { - if (!jp[j].jp_ctltype && jailparam_type(jp + j) < 0) - return (-1); if (!strcmp(jp[j].jp_name, "lastjid")) jp_lastjid = jp + j; else if (!strcmp(jp[j].jp_name, "jid")) @@ -725,8 +721,6 @@ jailparam_export(struct jailparam *jp) int i, nval, ival; char valbuf[INET6_ADDRSTRLEN]; - if (!jp->jp_ctltype && jailparam_type(jp) < 0) - return (NULL); if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) { value = strdup(jp->jp_value); if (value == NULL)