svn commit: r214424 - projects/jailconf/usr.sbin/jail

Jamie Gritton jamie at FreeBSD.org
Wed Oct 27 16:35:23 UTC 2010


Author: jamie
Date: Wed Oct 27 16:35:23 2010
New Revision: 214424
URL: http://svn.freebsd.org/changeset/base/214424

Log:
  Don't assume either jid or name is set - they may not be from the
  command line.

Modified:
  projects/jailconf/usr.sbin/jail/jail.c

Modified: projects/jailconf/usr.sbin/jail/jail.c
==============================================================================
--- projects/jailconf/usr.sbin/jail/jail.c	Wed Oct 27 16:22:54 2010	(r214423)
+++ projects/jailconf/usr.sbin/jail/jail.c	Wed Oct 27 16:35:23 2010	(r214424)
@@ -891,8 +891,7 @@ running_jid(struct cfjail *j, int dflag)
 	char *ep;
 	int jid;
 
-	pval = string_param(j->intparams[KP_JID]);
-	if (pval != NULL) {
+	if ((pval = string_param(j->intparams[KP_JID]))) {
 		if (!(jid = strtol(pval, &ep, 10)) || *ep) {
 			j->jid = -1;
 			return;
@@ -901,13 +900,15 @@ running_jid(struct cfjail *j, int dflag)
 		jiov[0].iov_len = sizeof("jid");
 		jiov[1].iov_base = &jid;
 		jiov[1].iov_len = sizeof(jid);
-	} else {
-		pval = string_param(j->intparams[KP_NAME]);
+	} else if ((pval = string_param(j->intparams[KP_NAME]))) {
 		*(const void **)&jiov[0].iov_base = "name";
 		jiov[0].iov_len = sizeof("name");
 		jiov[1].iov_len = strlen(pval) + 1;
 		jiov[1].iov_base = alloca(jiov[1].iov_len);
 		strcpy(jiov[1].iov_base, pval);
+	} else {
+		j->jid = -1;
+		return;
 	}
 	j->jid = jail_get(jiov, 2, dflag ? JAIL_DYING : 0);
 }


More information about the svn-src-projects mailing list