Date: Mon, 4 Jan 2016 03:22:07 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r293133 - in stable/9/usr.sbin/cron: cron crontab Message-ID: <201601040322.u043M7B5007541@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Mon Jan 4 03:22:06 2016 New Revision: 293133 URL: https://svnweb.freebsd.org/changeset/base/293133 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/9/usr.sbin/cron/cron/do_command.c stable/9/usr.sbin/cron/cron/popen.c stable/9/usr.sbin/cron/crontab/crontab.c Directory Properties: stable/9/usr.sbin/cron/ (props changed) stable/9/usr.sbin/cron/crontab/ (props changed) Modified: stable/9/usr.sbin/cron/cron/do_command.c ============================================================================== --- stable/9/usr.sbin/cron/cron/do_command.c Mon Jan 4 03:20:41 2016 (r293132) +++ stable/9/usr.sbin/cron/cron/do_command.c Mon Jan 4 03:22:06 2016 (r293133) @@ -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/9/usr.sbin/cron/cron/popen.c ============================================================================== --- stable/9/usr.sbin/cron/cron/popen.c Mon Jan 4 03:20:41 2016 (r293132) +++ stable/9/usr.sbin/cron/cron/popen.c Mon Jan 4 03:22:06 2016 (r293133) @@ -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/9/usr.sbin/cron/crontab/crontab.c ============================================================================== --- stable/9/usr.sbin/cron/crontab/crontab.c Mon Jan 4 03:20:41 2016 (r293132) +++ stable/9/usr.sbin/cron/crontab/crontab.c Mon Jan 4 03:22:06 2016 (r293133) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601040322.u043M7B5007541>