config.c (239601) | config.c (239621) |
---|---|
1/*- 2 * Copyright (c) 2011 James Gritton 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011 James Gritton 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/usr.sbin/jail/config.c 239601 2012-08-23 01:43:01Z jamie $"); | 28__FBSDID("$FreeBSD: head/usr.sbin/jail/config.c 239621 2012-08-23 19:39:23Z jamie $"); |
29 30#include <sys/types.h> 31#include <sys/errno.h> 32#include <sys/socket.h> 33#include <sys/sysctl.h> 34 35#include <arpa/inet.h> 36#include <netinet/in.h> --- 555 unchanged lines hidden (view full) --- 592 prefix = strtol(cs + 1, &ep, 10); 593 if (*ep == '.' 594 ? inet_pton(AF_INET, cs + 1, &addr4) != 1 595 : *ep || prefix < 0 || prefix > 32) { 596 jail_warnx(j, 597 "ip4.addr: bad netmask \"%s\"", cs); 598 error = -1; 599 } | 29 30#include <sys/types.h> 31#include <sys/errno.h> 32#include <sys/socket.h> 33#include <sys/sysctl.h> 34 35#include <arpa/inet.h> 36#include <netinet/in.h> --- 555 unchanged lines hidden (view full) --- 592 prefix = strtol(cs + 1, &ep, 10); 593 if (*ep == '.' 594 ? inet_pton(AF_INET, cs + 1, &addr4) != 1 595 : *ep || prefix < 0 || prefix > 32) { 596 jail_warnx(j, 597 "ip4.addr: bad netmask \"%s\"", cs); 598 error = -1; 599 } |
600 *cs = '\0'; |
|
600 s->len = cs - s->s; 601 } 602 } 603 } 604#endif 605#ifdef INET6 606 if (j->intparams[KP_IP6_ADDR] != NULL) { 607 TAILQ_FOREACH(s, &j->intparams[KP_IP6_ADDR]->val, tq) { --- 7 unchanged lines hidden (view full) --- 615 if ((cs = strchr(s->s, '/'))) { 616 prefix = strtol(cs + 1, &ep, 10); 617 if (*ep || prefix < 0 || prefix > 128) { 618 jail_warnx(j, 619 "ip6.addr: bad prefixlen \"%s\"", 620 cs); 621 error = -1; 622 } | 601 s->len = cs - s->s; 602 } 603 } 604 } 605#endif 606#ifdef INET6 607 if (j->intparams[KP_IP6_ADDR] != NULL) { 608 TAILQ_FOREACH(s, &j->intparams[KP_IP6_ADDR]->val, tq) { --- 7 unchanged lines hidden (view full) --- 616 if ((cs = strchr(s->s, '/'))) { 617 prefix = strtol(cs + 1, &ep, 10); 618 if (*ep || prefix < 0 || prefix > 128) { 619 jail_warnx(j, 620 "ip6.addr: bad prefixlen \"%s\"", 621 cs); 622 error = -1; 623 } |
624 *cs = '\0'; |
|
623 s->len = cs - s->s; 624 } 625 } 626 } 627#endif 628#endif 629 630 /* --- 77 unchanged lines hidden (view full) --- 708 */ 709 vallen = 0; 710 TAILQ_FOREACH(s, &p->val, tq) 711 vallen += s->len + 1; 712 value = alloca(vallen); 713 cs = value; 714 TAILQ_FOREACH_SAFE(s, &p->val, tq, ts) { 715 memcpy(cs, s->s, s->len); | 625 s->len = cs - s->s; 626 } 627 } 628 } 629#endif 630#endif 631 632 /* --- 77 unchanged lines hidden (view full) --- 710 */ 711 vallen = 0; 712 TAILQ_FOREACH(s, &p->val, tq) 713 vallen += s->len + 1; 714 value = alloca(vallen); 715 cs = value; 716 TAILQ_FOREACH_SAFE(s, &p->val, tq, ts) { 717 memcpy(cs, s->s, s->len); |
716 if (ts != NULL) { 717 cs += s->len + 1; 718 cs[-1] = ','; 719 } | 718 cs += s->len + 1; 719 cs[-1] = ','; |
720 } | 720 } |
721 value[vallen - 1] = '\0'; |
|
721 } 722 if (jailparam_import(jp, value) < 0) { 723 error = -1; 724 jail_warnx(j, "%s", jail_errmsg); 725 } 726 jp++; 727 } 728 if (error) { --- 103 unchanged lines hidden --- | 722 } 723 if (jailparam_import(jp, value) < 0) { 724 error = -1; 725 jail_warnx(j, "%s", jail_errmsg); 726 } 727 jp++; 728 } 729 if (error) { --- 103 unchanged lines hidden --- |