svn commit: r239854 - stable/9/usr.sbin/jail
Jamie Gritton
jamie at FreeBSD.org
Wed Aug 29 16:11:04 UTC 2012
Author: jamie
Date: Wed Aug 29 16:11:03 2012
New Revision: 239854
URL: http://svn.freebsd.org/changeset/base/239854
Log:
MFC r239601:
Remember that I'm using length-defined strings in parameters:
Remove a bogus null terminator when stripping the netmask from
IP addresses. This was causing later addresses in a comma-separated
string to disappear.
Use memcpy instead of strcpy. This could just cause Bad Things.
MFC r239602:
Pre-separate IP addresses passed on the command line, so they can be
properly parsed for interface prefixes and netmask suffixes. This was
already done for the old-style (fixed) command line, but missed for
the new-style.
MFC r239621:
Partially roll back r239601 - keep parameter strings both length-delimited
and null-terminated at the same time, because they're later passed to
libjail as null-terminated. That means I also need to add a nul byte when
comma-combining array parameters.
PR: 170832
Modified:
stable/9/usr.sbin/jail/config.c
stable/9/usr.sbin/jail/jail.c
Directory Properties:
stable/9/usr.sbin/jail/ (props changed)
Modified: stable/9/usr.sbin/jail/config.c
==============================================================================
--- stable/9/usr.sbin/jail/config.c Wed Aug 29 16:00:26 2012 (r239853)
+++ stable/9/usr.sbin/jail/config.c Wed Aug 29 16:11:03 2012 (r239854)
@@ -596,7 +596,7 @@ check_intparams(struct cfjail *j)
error = -1;
}
*cs = '\0';
- s->len = cs - s->s + 1;
+ s->len = cs - s->s;
}
}
}
@@ -620,7 +620,7 @@ check_intparams(struct cfjail *j)
error = -1;
}
*cs = '\0';
- s->len = cs - s->s + 1;
+ s->len = cs - s->s;
}
}
}
@@ -712,12 +712,11 @@ import_params(struct cfjail *j)
value = alloca(vallen);
cs = value;
TAILQ_FOREACH_SAFE(s, &p->val, tq, ts) {
- strcpy(cs, s->s);
- if (ts != NULL) {
- cs += s->len + 1;
- cs[-1] = ',';
- }
+ memcpy(cs, s->s, s->len);
+ cs += s->len + 1;
+ cs[-1] = ',';
}
+ value[vallen - 1] = '\0';
}
if (jailparam_import(jp, value) < 0) {
error = -1;
Modified: stable/9/usr.sbin/jail/jail.c
==============================================================================
--- stable/9/usr.sbin/jail/jail.c Wed Aug 29 16:00:26 2012 (r239853)
+++ stable/9/usr.sbin/jail/jail.c Wed Aug 29 16:11:03 2012 (r239854)
@@ -304,9 +304,33 @@ main(int argc, char **argv)
for (i++; i < argc; i++)
add_param(NULL, NULL, IP_COMMAND,
argv[i]);
- break;
}
- add_param(NULL, NULL, 0, argv[i]);
+#ifdef INET
+ else if (!strncmp(argv[i], "ip4.addr=", 9)) {
+ for (cs = argv[i] + 9;; cs = ncs + 1) {
+ ncs = strchr(cs, ',');
+ if (ncs)
+ *ncs = '\0';
+ add_param(NULL, NULL, KP_IP4_ADDR, cs);
+ if (!ncs)
+ break;
+ }
+ }
+#endif
+#ifdef INET6
+ else if (!strncmp(argv[i], "ip6.addr=", 9)) {
+ for (cs = argv[i] + 9;; cs = ncs + 1) {
+ ncs = strchr(cs, ',');
+ if (ncs)
+ *ncs = '\0';
+ add_param(NULL, NULL, KP_IP6_ADDR, cs);
+ if (!ncs)
+ break;
+ }
+ }
+#endif
+ else
+ add_param(NULL, NULL, 0, argv[i]);
}
} else {
/* From the config file, perhaps with a specified jail */
More information about the svn-src-stable
mailing list