From owner-svn-src-all@freebsd.org Mon Jan 4 03:20:43 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 7B26FA61B16; Mon, 4 Jan 2016 03:20:43 +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 3433C181C; Mon, 4 Jan 2016 03:20:43 +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 u043KgSv004892; Mon, 4 Jan 2016 03:20:42 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u043Kglj004888; Mon, 4 Jan 2016 03:20:42 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201601040320.u043Kglj004888@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 4 Jan 2016 03:20:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r293132 - in stable/10/usr.sbin/cron: cron crontab X-SVN-Group: stable-10 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.20 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: Mon, 04 Jan 2016 03:20:43 -0000 Author: pfg Date: Mon Jan 4 03:20:41 2016 New Revision: 293132 URL: https://svnweb.freebsd.org/changeset/base/293132 Log: MFC r292605, r292606, r292607, r292608: cron: bring some fixes for Coverity reports and other issues. crontab: replace malloc + bzero with calloc crontab: properly free an entry cron: Check the return value of pipe(2) CID: 271773, 1009830, Modified: stable/10/usr.sbin/cron/cron/do_command.c stable/10/usr.sbin/cron/cron/popen.c stable/10/usr.sbin/cron/crontab/crontab.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/cron/cron/do_command.c ============================================================================== --- stable/10/usr.sbin/cron/cron/do_command.c Mon Jan 4 03:12:18 2016 (r293131) +++ stable/10/usr.sbin/cron/cron/do_command.c Mon Jan 4 03:20:41 2016 (r293132) @@ -161,8 +161,10 @@ child_process(e, u) /* create some pipes to talk to our future child */ - pipe(stdin_pipe); /* child's stdin */ - pipe(stdout_pipe); /* child's stdout */ + if (pipe(stdin_pipe) != 0 || pipe(stdout_pipe) != 0) { + log_it("CRON", getpid(), "error", "can't pipe"); + exit(ERROR_EXIT); + } /* since we are a forked process, we can diddle the command string * we were passed -- nobody else is going to use it again, right? Modified: stable/10/usr.sbin/cron/cron/popen.c ============================================================================== --- stable/10/usr.sbin/cron/cron/popen.c Mon Jan 4 03:12:18 2016 (r293131) +++ stable/10/usr.sbin/cron/cron/popen.c Mon Jan 4 03:20:41 2016 (r293132) @@ -82,9 +82,8 @@ cron_popen(program, type, e) if (!pids) { if ((fds = getdtablesize()) <= 0) return(NULL); - if (!(pids = (PID_T *)malloc((u_int)(fds * sizeof(PID_T))))) + if (!(pids = calloc(fds, sizeof(PID_T)))) return(NULL); - bzero((char *)pids, fds * sizeof(PID_T)); } if (pipe(pdes) < 0) return(NULL); Modified: stable/10/usr.sbin/cron/crontab/crontab.c ============================================================================== --- stable/10/usr.sbin/cron/crontab/crontab.c Mon Jan 4 03:12:18 2016 (r293131) +++ stable/10/usr.sbin/cron/crontab/crontab.c Mon Jan 4 03:20:41 2016 (r293132) @@ -558,7 +558,7 @@ replace_cmd() { case FALSE: e = load_entry(tmp, check_error, pw, envp); if (e) - free(e); + free_entry(e); break; case TRUE: break;