From owner-svn-src-all@freebsd.org Sun May 15 03:04:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93239B3B814; Sun, 15 May 2016 03:04:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A1191350; Sun, 15 May 2016 03:04:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4F34Lsl052831; Sun, 15 May 2016 03:04:21 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4F34LGR052829; Sun, 15 May 2016 03:04:21 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201605150304.u4F34LGR052829@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 15 May 2016 03:04:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299825 - head/sbin/routed X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 May 2016 03:04:22 -0000 Author: pfg Date: Sun May 15 03:04:21 2016 New Revision: 299825 URL: https://svnweb.freebsd.org/changeset/base/299825 Log: routed(8): Misc. cleanups to squelch Coverity. table.c: Copy into fixed size buffer. trace.c: Argument got dup2() cannot be negative. Copy into fixed size buffer. CID: 1006785, 1006786, 271301 Obtained from: NetBSD MFC after: 2 weeks. Modified: head/sbin/routed/table.c head/sbin/routed/trace.c Modified: head/sbin/routed/table.c ============================================================================== --- head/sbin/routed/table.c Sun May 15 03:01:40 2016 (r299824) +++ head/sbin/routed/table.c Sun May 15 03:04:21 2016 (r299825) @@ -1228,7 +1228,7 @@ read_rt(void) continue; /* ignore compat message */ #endif - strcpy(str, rtm_type_name(m.r.rtm.rtm_type)); + strlcpy(str, rtm_type_name(m.r.rtm.rtm_type), sizeof(str)); strp = &str[strlen(str)]; if (m.r.rtm.rtm_type <= RTM_CHANGE) strp += sprintf(strp," from pid %d",m.r.rtm.rtm_pid); Modified: head/sbin/routed/trace.c ============================================================================== --- head/sbin/routed/trace.c Sun May 15 03:01:40 2016 (r299824) +++ head/sbin/routed/trace.c Sun May 15 03:04:21 2016 (r299825) @@ -205,6 +205,8 @@ trace_close(int zap_stdio) fclose(ftrace); ftrace = NULL; fd = open(_PATH_DEVNULL, O_RDWR); + if (fd < 0) + return; if (isatty(STDIN_FILENO)) (void)dup2(fd, STDIN_FILENO); if (isatty(STDOUT_FILENO)) @@ -439,9 +441,12 @@ addrname(naddr addr, /* in network byt } bufs[NUM_BUFS]; char *s, *sp; naddr dmask; + size_t l; int i; - s = strcpy(bufs[bufno].str, naddr_ntoa(addr)); + strlcpy(bufs[bufno].str, naddr_ntoa(addr), sizeof(bufs[bufno].str)); + s = bufs[bufno].str; + l = sizeof(bufs[bufno].str); bufno = (bufno+1) % NUM_BUFS; if (force == 1 || (force == 0 && mask != std_mask(addr))) { @@ -451,10 +456,11 @@ addrname(naddr addr, /* in network byt if (mask + dmask == 0) { for (i = 0; i != 32 && ((1<