From owner-svn-src-stable-7@FreeBSD.ORG Tue Oct 4 11:10:12 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 554DE106566B; Tue, 4 Oct 2011 11:10:12 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B33A8FC0A; Tue, 4 Oct 2011 11:10:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p94BACgh054871; Tue, 4 Oct 2011 11:10:12 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p94BACvW054868; Tue, 4 Oct 2011 11:10:12 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201110041110.p94BACvW054868@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 4 Oct 2011 11:10:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225968 - stable/7/usr.bin/script X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 11:10:12 -0000 Author: trociny Date: Tue Oct 4 11:10:11 2011 New Revision: 225968 URL: http://svn.freebsd.org/changeset/base/225968 Log: MFC r225809: When script(1) reads EOF from input it starts spinning on zero-byte reads eating 100% CPU. Fix this by skipping select on STDIN after reading EOF -- permanently if STDIN is not terminal and for one second if it is. Also after reading EOF from STDIN we have to pass it to the program being scripted. The previous approach was to write zero bytes into the pseudo-terminal. This does not work because zero-byte write does not have any effect on read. Fix this by sending VEOF instead. Reported by: Ronald Klop Discussed with: kib, Chris Torek Modified: stable/7/usr.bin/script/script.1 stable/7/usr.bin/script/script.c Directory Properties: stable/7/usr.bin/script/ (props changed) Modified: stable/7/usr.bin/script/script.1 ============================================================================== --- stable/7/usr.bin/script/script.1 Tue Oct 4 11:08:44 2011 (r225967) +++ stable/7/usr.bin/script/script.1 Tue Oct 4 11:10:11 2011 (r225968) @@ -170,3 +170,12 @@ The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when in a raw mode where the program being run is doing manual echo. +.Pp +If the +.Nm +reads zero bytes from the terminal it switches to a mode when it probes read +only once a second until it gets some data. +This prevents the +.Nm +spinning on zero-byte reads, but might cause a 1-second delay in +processing of the user input. Modified: stable/7/usr.bin/script/script.c ============================================================================== --- stable/7/usr.bin/script/script.c Tue Oct 4 11:08:44 2011 (r225967) +++ stable/7/usr.bin/script/script.c Tue Oct 4 11:10:11 2011 (r225968) @@ -91,6 +91,7 @@ main(int argc, char *argv[]) char ibuf[BUFSIZ]; fd_set rfd; int flushtime = 30; + int readstdin; aflg = kflg = 0; while ((ch = getopt(argc, argv, "aqkt:")) != -1) @@ -159,19 +160,21 @@ main(int argc, char *argv[]) if (child == 0) doshell(argv); - if (flushtime > 0) - tvp = &tv; - else - tvp = NULL; - - start = time(0); - FD_ZERO(&rfd); + start = tvec = time(0); + readstdin = 1; for (;;) { + FD_ZERO(&rfd); FD_SET(master, &rfd); - FD_SET(STDIN_FILENO, &rfd); - if (flushtime > 0) { - tv.tv_sec = flushtime; + if (readstdin) + FD_SET(STDIN_FILENO, &rfd); + if ((!readstdin && ttyflg) || flushtime > 0) { + tv.tv_sec = !readstdin && ttyflg ? 1 : + flushtime - (tvec - start); tv.tv_usec = 0; + tvp = &tv; + readstdin = 1; + } else { + tvp = NULL; } n = select(master + 1, &rfd, 0, 0, tvp); if (n < 0 && errno != EINTR) @@ -180,8 +183,13 @@ main(int argc, char *argv[]) cc = read(STDIN_FILENO, ibuf, BUFSIZ); if (cc < 0) break; - if (cc == 0) - (void)write(master, ibuf, 0); + if (cc == 0) { + if (tcgetattr(master, &stt) == 0 && + (stt.c_lflag & ICANON) != 0) { + (void)write(master, &stt.c_cc[VEOF], 1); + } + readstdin = 0; + } if (cc > 0) { (void)write(master, ibuf, cc); if (kflg && tcgetattr(master, &stt) >= 0 && From owner-svn-src-stable-7@FreeBSD.ORG Tue Oct 4 13:19:22 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61B15106564A; Tue, 4 Oct 2011 13:19:22 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4F96B8FC12; Tue, 4 Oct 2011 13:19:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p94DJMGM059294; Tue, 4 Oct 2011 13:19:22 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p94DJMt3059288; Tue, 4 Oct 2011 13:19:22 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201110041319.p94DJMt3059288@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Tue, 4 Oct 2011 13:19:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225976 - stable/7/sys/net X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 13:19:22 -0000 Author: bz Date: Tue Oct 4 13:19:21 2011 New Revision: 225976 URL: http://svn.freebsd.org/changeset/base/225976 Log: MFC r225837: Pass the fibnum where we need filtering of the message on the rtsock allowing routing daemons to filter routing updates on an rtsock per FIB. Adjust raw_input() and split it into wrapper and a new function taking an optional callback argument even though we only have one consumer [1] to keep the hackish flags local to rtsock.c. PR: kern/134931 Submitted by: multiple (see PR) Suggested by: rwatson [1] Reviewed by: rwatson Modified: stable/7/sys/net/raw_cb.h stable/7/sys/net/raw_usrreq.c stable/7/sys/net/route.c stable/7/sys/net/route.h stable/7/sys/net/rtsock.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/net/raw_cb.h ============================================================================== --- stable/7/sys/net/raw_cb.h Tue Oct 4 13:18:14 2011 (r225975) +++ stable/7/sys/net/raw_cb.h Tue Oct 4 13:19:21 2011 (r225976) @@ -68,9 +68,14 @@ pr_init_t raw_init; * Library routines for raw socket usrreq functions; will always be wrapped * so that protocol-specific functions can be handled. */ +typedef int (*raw_input_cb_fn)(struct mbuf *, struct sockproto *, + struct sockaddr *, struct rawcb *); + int raw_attach(struct socket *, int); void raw_detach(struct rawcb *); void raw_input(struct mbuf *, struct sockproto *, struct sockaddr *); +void raw_input_ext(struct mbuf *, struct sockproto *, struct sockaddr *, + raw_input_cb_fn); /* * Generic pr_usrreqs entries for raw socket protocols, usually wrapped so Modified: stable/7/sys/net/raw_usrreq.c ============================================================================== --- stable/7/sys/net/raw_usrreq.c Tue Oct 4 13:18:14 2011 (r225975) +++ stable/7/sys/net/raw_usrreq.c Tue Oct 4 13:19:21 2011 (r225976) @@ -69,6 +69,14 @@ raw_init(void) void raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src) { + + return (raw_input_ext(m0, proto, src, NULL)); +} + +void +raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, + raw_input_cb_fn cb) +{ struct rawcb *rp; struct mbuf *m = m0; struct socket *last; @@ -81,6 +89,8 @@ raw_input(struct mbuf *m0, struct sockpr if (rp->rcb_proto.sp_protocol && rp->rcb_proto.sp_protocol != proto->sp_protocol) continue; + if (cb != NULL && (*cb)(m, proto, src, rp) != 0) + continue; if (last) { struct mbuf *n; n = m_copy(m, 0, (int)M_COPYALL); Modified: stable/7/sys/net/route.c ============================================================================== --- stable/7/sys/net/route.c Tue Oct 4 13:18:14 2011 (r225975) +++ stable/7/sys/net/route.c Tue Oct 4 13:19:21 2011 (r225976) @@ -344,7 +344,8 @@ rtalloc1_fib(struct sockaddr *dst, int r newrt->rt_ifp->if_addr->ifa_addr; info.rti_info[RTAX_IFA] = newrt->rt_ifa->ifa_addr; } - rt_missmsg(RTM_ADD, &info, newrt->rt_flags, 0); + rt_missmsg_fib(RTM_ADD, &info, newrt->rt_flags, 0, + fibnum); } else { KASSERT(rt == newrt, ("locking wrong route")); RT_LOCK(newrt); @@ -370,7 +371,7 @@ rtalloc1_fib(struct sockaddr *dst, int r */ bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; - rt_missmsg(msgtype, &info, 0, err); + rt_missmsg_fib(msgtype, &info, 0, err, fibnum); } } if (newrt) @@ -591,7 +592,7 @@ out: info.rti_info[RTAX_GATEWAY] = gateway; info.rti_info[RTAX_NETMASK] = netmask; info.rti_info[RTAX_AUTHOR] = src; - rt_missmsg(RTM_REDIRECT, &info, flags, error); + rt_missmsg_fib(RTM_REDIRECT, &info, flags, error, fibnum); } int @@ -1482,7 +1483,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int * notify any listening routing agents of the change */ RT_LOCK(rt); - rt_newaddrmsg(cmd, ifa, error, rt); + rt_newaddrmsg_fib(cmd, ifa, error, rt, fibnum); if (cmd == RTM_DELETE) { /* * If we are deleting, and we found an entry, then Modified: stable/7/sys/net/route.h ============================================================================== --- stable/7/sys/net/route.h Tue Oct 4 13:18:14 2011 (r225975) +++ stable/7/sys/net/route.h Tue Oct 4 13:19:21 2011 (r225976) @@ -351,7 +351,9 @@ void rt_ieee80211msg(struct ifnet *, in void rt_ifannouncemsg(struct ifnet *, int); void rt_ifmsg(struct ifnet *); void rt_missmsg(int, struct rt_addrinfo *, int, int); +void rt_missmsg_fib(int, struct rt_addrinfo *, int, int, int); void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *); +void rt_newaddrmsg_fib(int, struct ifaddr *, int, struct rtentry *, int); void rt_newmaddrmsg(int, struct ifmultiaddr *); int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *); Modified: stable/7/sys/net/rtsock.c ============================================================================== --- stable/7/sys/net/rtsock.c Tue Oct 4 13:18:14 2011 (r225975) +++ stable/7/sys/net/rtsock.c Tue Oct 4 13:19:21 2011 (r225976) @@ -68,6 +68,13 @@ MALLOC_DEFINE(M_RTABLE, "routetbl", "rou static struct sockaddr route_src = { 2, PF_ROUTE, }; static struct sockaddr sa_zero = { sizeof(sa_zero), AF_INET, }; +/* + * Used by rtsock/raw_input callback code to decide whether to filter the update + * notification to a socket bound to a particular FIB. + */ +#define RTS_FILTER_FIB M_PROTO8 +#define RTS_ALLFIBS -1 + static struct { int ip_count; /* attached w/ AF_INET */ int ip6_count; /* attached w/ AF_INET6 */ @@ -124,6 +131,31 @@ rts_init(void) } SYSINIT(rtsock, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rts_init, 0); +static int +raw_input_rts_cb(struct mbuf *m, struct sockproto *proto, struct sockaddr *src, + struct rawcb *rp) +{ + int fibnum; + + KASSERT(m != NULL, ("%s: m is NULL", __func__)); + KASSERT(proto != NULL, ("%s: proto is NULL", __func__)); + KASSERT(rp != NULL, ("%s: rp is NULL", __func__)); + + /* No filtering requested. */ + if ((m->m_flags & RTS_FILTER_FIB) == 0) + return (0); + + /* Check if it is a rts and the fib matches the one of the socket. */ + fibnum = M_GETFIB(m); + if (proto->sp_family != PF_ROUTE || + rp->rcb_socket == NULL || + rp->rcb_socket->so_fibnum == fibnum) + return (0); + + /* Filtering requested and no match, the socket shall be skipped. */ + return (1); +} + static void rts_input(struct mbuf *m) { @@ -140,7 +172,7 @@ rts_input(struct mbuf *m) } else route_proto.sp_protocol = 0; - raw_input(m, &route_proto, &route_src); + raw_input_ext(m, &route_proto, &route_src, raw_input_rts_cb); } /* @@ -727,6 +759,8 @@ flush: Free(rtm); } if (m) { + M_SETFIB(m, so->so_fibnum); + m->m_flags |= RTS_FILTER_FIB; if (rp) { /* * XXX insure we don't get a copy by @@ -958,7 +992,8 @@ again: * destination. */ void -rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error) +rt_missmsg_fib(int type, struct rt_addrinfo *rtinfo, int flags, int error, + int fibnum) { struct rt_msghdr *rtm; struct mbuf *m; @@ -969,6 +1004,14 @@ rt_missmsg(int type, struct rt_addrinfo m = rt_msg1(type, rtinfo); if (m == NULL) return; + + if (fibnum != RTS_ALLFIBS) { + KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: fibnum out " + "of range 0 <= %d < %d", __func__, fibnum, rt_numfibs)); + M_SETFIB(m, fibnum); + m->m_flags |= RTS_FILTER_FIB; + } + rtm = mtod(m, struct rt_msghdr *); rtm->rtm_flags = RTF_DONE | flags; rtm->rtm_errno = error; @@ -976,6 +1019,13 @@ rt_missmsg(int type, struct rt_addrinfo rt_dispatch(m, sa); } +void +rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error) +{ + + rt_missmsg_fib(type, rtinfo, flags, error, RTS_ALLFIBS); +} + /* * This routine is called to generate a message from the routing * socket indicating that the status of a network interface has changed. @@ -1010,7 +1060,8 @@ rt_ifmsg(struct ifnet *ifp) * copies of it. */ void -rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) +rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt, + int fibnum) { struct rt_addrinfo info; struct sockaddr *sa = NULL; @@ -1066,10 +1117,24 @@ rt_newaddrmsg(int cmd, struct ifaddr *if rtm->rtm_errno = error; rtm->rtm_addrs = info.rti_addrs; } + if (fibnum != RTS_ALLFIBS) { + KASSERT(fibnum >= 0 && fibnum < rt_numfibs, ("%s: " + "fibnum out of range 0 <= %d < %d", __func__, + fibnum, rt_numfibs)); + M_SETFIB(m, fibnum); + m->m_flags |= RTS_FILTER_FIB; + } rt_dispatch(m, sa); } } +void +rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) +{ + + rt_newaddrmsg_fib(cmd, ifa, error, rt, RTS_ALLFIBS); +} + /* * This is the analogue to the rt_newaddrmsg which performs the same * function but for multicast group memberhips. This is easier since From owner-svn-src-stable-7@FreeBSD.ORG Tue Oct 4 19:07:39 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78B361065679; Tue, 4 Oct 2011 19:07:39 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B70C8FC0C; Tue, 4 Oct 2011 19:07:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p94J7dgm075276; Tue, 4 Oct 2011 19:07:39 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p94J7d0x075274; Tue, 4 Oct 2011 19:07:39 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201110041907.p94J7d0x075274@svn.freebsd.org> From: Colin Percival Date: Tue, 4 Oct 2011 19:07:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226023 - head/sys/compat/linux releng/7.3 releng/7.3/sys/compat/linux releng/7.3/sys/conf releng/7.4 releng/7.4/sys/compat/linux releng/7.4/sys/conf releng/8.1 releng/8.1/sys/compat/li... X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 19:07:39 -0000 Author: cperciva Date: Tue Oct 4 19:07:38 2011 New Revision: 226023 URL: http://svn.freebsd.org/changeset/base/226023 Log: Fix a bug in UNIX socket handling in the linux emulator which was exposed by the security fix in FreeBSD-SA-11:05.unix. Approved by: so (cperciva) Approved by: re (kib) Security: Related to FreeBSD-SA-11:05.unix, but not actually a security fix. Modified: stable/7/sys/compat/linux/linux_socket.c Changes in other areas also in this revision: Modified: head/sys/compat/linux/linux_socket.c releng/7.3/UPDATING releng/7.3/sys/compat/linux/linux_socket.c releng/7.3/sys/conf/newvers.sh releng/7.4/UPDATING releng/7.4/sys/compat/linux/linux_socket.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/sys/compat/linux/linux_socket.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/sys/compat/linux/linux_socket.c releng/8.2/sys/conf/newvers.sh stable/8/sys/compat/linux/linux_socket.c stable/9/sys/compat/linux/linux_socket.c Modified: stable/7/sys/compat/linux/linux_socket.c ============================================================================== --- stable/7/sys/compat/linux/linux_socket.c Tue Oct 4 18:45:29 2011 (r226022) +++ stable/7/sys/compat/linux/linux_socket.c Tue Oct 4 19:07:38 2011 (r226023) @@ -101,6 +101,7 @@ do_sa_get(struct sockaddr **sap, const s int oldv6size; struct sockaddr_in6 *sin6; #endif + int namelen; if (*osalen < 2 || *osalen > UCHAR_MAX || !osa) return (EINVAL); @@ -163,6 +164,20 @@ do_sa_get(struct sockaddr **sap, const s } } + if ((bdom == AF_LOCAL) && (*osalen > sizeof(struct sockaddr_un))) { + for (namelen = 0; + namelen < *osalen - offsetof(struct sockaddr_un, sun_path); + namelen++) + if (!((struct sockaddr_un *)kosa)->sun_path[namelen]) + break; + if (namelen + offsetof(struct sockaddr_un, sun_path) > + sizeof(struct sockaddr_un)) { + error = EINVAL; + goto out; + } + alloclen = sizeof(struct sockaddr_un); + } + sa = (struct sockaddr *) kosa; sa->sa_family = bdom; sa->sa_len = alloclen; From owner-svn-src-stable-7@FreeBSD.ORG Wed Oct 5 15:52:40 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7214A106566B; Wed, 5 Oct 2011 15:52:40 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 614BE8FC17; Wed, 5 Oct 2011 15:52:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p95FqepI018568; Wed, 5 Oct 2011 15:52:40 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p95FqebU018566; Wed, 5 Oct 2011 15:52:40 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201110051552.p95FqebU018566@svn.freebsd.org> From: Jung-uk Kim Date: Wed, 5 Oct 2011 15:52:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226038 - stable/7/include X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2011 15:52:40 -0000 Author: jkim Date: Wed Oct 5 15:52:40 2011 New Revision: 226038 URL: http://svn.freebsd.org/changeset/base/226038 Log: MFC: r225801 Avoid accidental conflicts with C++ operator keywords. Modified: stable/7/include/iso646.h Directory Properties: stable/7/include/ (props changed) Modified: stable/7/include/iso646.h ============================================================================== --- stable/7/include/iso646.h Wed Oct 5 15:52:04 2011 (r226037) +++ stable/7/include/iso646.h Wed Oct 5 15:52:40 2011 (r226038) @@ -29,6 +29,8 @@ #ifndef _ISO646_H_ #define _ISO646_H_ +#ifndef __cplusplus + #define and && #define and_eq &= #define bitand & @@ -41,4 +43,6 @@ #define xor ^ #define xor_eq ^= +#endif /* !__cplusplus */ + #endif /* !_ISO646_H_ */ From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 7 14:27:20 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F6D3106567F; Fri, 7 Oct 2011 14:27:20 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E44B8FC08; Fri, 7 Oct 2011 14:27:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p97ERKrF014742; Fri, 7 Oct 2011 14:27:20 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p97ERK5U014740; Fri, 7 Oct 2011 14:27:20 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201110071427.p97ERK5U014740@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 7 Oct 2011 14:27:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226106 - stable/7/usr.bin/rs X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2011 14:27:20 -0000 Author: jh Date: Fri Oct 7 14:27:20 2011 New Revision: 226106 URL: http://svn.freebsd.org/changeset/base/226106 Log: MFC r218410: Handle EOF when skipping lines. Modified: stable/7/usr.bin/rs/rs.c Directory Properties: stable/7/usr.bin/rs/ (props changed) Modified: stable/7/usr.bin/rs/rs.c ============================================================================== --- stable/7/usr.bin/rs/rs.c Fri Oct 7 13:43:01 2011 (r226105) +++ stable/7/usr.bin/rs/rs.c Fri Oct 7 14:27:20 2011 (r226106) @@ -130,14 +130,17 @@ getfile(void) char *p; char *endp; char **ep; + int c; int multisep = (flags & ONEISEPONLY ? 0 : 1); int nullpad = flags & NULLPAD; char **padto; while (skip--) { - getline(); + c = getline(); if (flags & SKIPPRINT) puts(curline); + if (c == EOF) + return; } getline(); if (flags & NOARGS && curlen < owidth) From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 7 14:29:15 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DC5F1065676; Fri, 7 Oct 2011 14:29:15 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 64EA88FC20; Fri, 7 Oct 2011 14:29:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p97ETFAU014845; Fri, 7 Oct 2011 14:29:15 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p97ETFaO014843; Fri, 7 Oct 2011 14:29:15 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201110071429.p97ETFaO014843@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 7 Oct 2011 14:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226107 - stable/7/usr.bin/rs X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2011 14:29:15 -0000 Author: jh Date: Fri Oct 7 14:29:15 2011 New Revision: 226107 URL: http://svn.freebsd.org/changeset/base/226107 Log: MFC r218411: - Use LINE_MAX from limits.h as the maximum line length instead of BUFSIZ. Use LINE_MAX * 2 as the buffer size (BSIZE). - Error out if we encounter a line longer than LINE_MAX. The previous behavior was to silently split long lines and produce corrupted output. PR: bin/151384 Modified: stable/7/usr.bin/rs/rs.c Directory Properties: stable/7/usr.bin/rs/ (props changed) Modified: stable/7/usr.bin/rs/rs.c ============================================================================== --- stable/7/usr.bin/rs/rs.c Fri Oct 7 14:27:20 2011 (r226106) +++ stable/7/usr.bin/rs/rs.c Fri Oct 7 14:29:15 2011 (r226107) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -333,8 +334,8 @@ prepfile(void) warnx("%d is colwidths, nelem %d", colwidths[i], nelem);*/ } -#define BSIZE 2048 -char ibuf[BSIZE]; /* two screenfuls should do */ +#define BSIZE (LINE_MAX * 2) +char ibuf[BSIZE]; int getline(void) /* get line; maintain curline, curlen; manage storage */ @@ -355,7 +356,7 @@ getline(void) /* get line; maintain curl curline = ibuf; } } - if (!putlength && endblock - curline < BUFSIZ) { /* need storage */ + if (!putlength && endblock - curline < LINE_MAX + 1) { /* need storage */ /*ww = endblock-curline; tt += ww;*/ /*printf("#wasted %d total %d\n",ww,tt);*/ if (!(curline = (char *) malloc(BSIZE))) @@ -363,11 +364,16 @@ getline(void) /* get line; maintain curl endblock = curline + BSIZE; /*printf("#endb %d curline %d\n",endblock,curline);*/ } - for (p = curline, i = 1; i < BUFSIZ; *p++ = c, i++) - if ((c = getchar()) == EOF || c == '\n') + for (p = curline, i = 0;; *p++ = c, i++) { + if ((c = getchar()) == EOF) break; + if (i >= LINE_MAX) + errx(1, "maximum line length (%d) exceeded", LINE_MAX); + if (c == '\n') + break; + } *p = '\0'; - curlen = i - 1; + curlen = i; return(c); } From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 7 14:30:45 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4F26106568B; Fri, 7 Oct 2011 14:30:45 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C43288FC0C; Fri, 7 Oct 2011 14:30:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p97EUjqc014946; Fri, 7 Oct 2011 14:30:45 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p97EUj7l014944; Fri, 7 Oct 2011 14:30:45 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201110071430.p97EUj7l014944@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 7 Oct 2011 14:30:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226108 - stable/7/usr.bin/rs X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2011 14:30:46 -0000 Author: jh Date: Fri Oct 7 14:30:45 2011 New Revision: 226108 URL: http://svn.freebsd.org/changeset/base/226108 Log: MFC r219038: Document the input line length limit. Modified: stable/7/usr.bin/rs/rs.1 Directory Properties: stable/7/usr.bin/rs/ (props changed) Modified: stable/7/usr.bin/rs/rs.1 ============================================================================== --- stable/7/usr.bin/rs/rs.1 Fri Oct 7 14:29:15 2011 (r226107) +++ stable/7/usr.bin/rs/rs.1 Fri Oct 7 14:30:45 2011 (r226108) @@ -32,7 +32,7 @@ .\" @(#)rs.1 8.2 (Berkeley) 12/30/93 .\" $FreeBSD$ .\" -.Dd July 30, 2004 +.Dd February 25, 2011 .Dt RS 1 .Os .Sh NAME @@ -241,4 +241,9 @@ Re-ordering of columns is not yet possib There are too many options. .It Multibyte characters are not recognized. +.It +Lines longer than +.Dv LINE_MAX +(2048) bytes are not processed and result in immediate termination of +.Nm . .El