From owner-svn-src-all@freebsd.org Mon Apr 18 15:01:50 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 8341DB1316B; Mon, 18 Apr 2016 15:01:50 +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 5100B1B94; Mon, 18 Apr 2016 15:01:50 +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 u3IF1nV6098309; Mon, 18 Apr 2016 15:01:49 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3IF1n1I098308; Mon, 18 Apr 2016 15:01:49 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604181501.u3IF1n1I098308@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 18 Apr 2016 15:01:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298211 - head/libexec/ftpd 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.21 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, 18 Apr 2016 15:01:50 -0000 Author: pfg Date: Mon Apr 18 15:01:49 2016 New Revision: 298211 URL: https://svnweb.freebsd.org/changeset/base/298211 Log: ftpd: replace malloc + memset 0 with calloc. It is faster and usually safer. Use NULL instead of zero for the pointer. Modified: head/libexec/ftpd/popen.c Modified: head/libexec/ftpd/popen.c ============================================================================== --- head/libexec/ftpd/popen.c Mon Apr 18 14:45:56 2016 (r298210) +++ head/libexec/ftpd/popen.c Mon Apr 18 15:01:49 2016 (r298211) @@ -81,9 +81,8 @@ ftpd_popen(char *program, char *type) if (!pids) { if ((fds = getdtablesize()) <= 0) return (NULL); - if ((pids = malloc(fds * sizeof(int))) == NULL) + if ((pids = calloc(fds, sizeof(int))) == NULL) return (NULL); - memset(pids, 0, fds * sizeof(int)); } if (pipe(pdes) < 0) return (NULL); @@ -185,7 +184,7 @@ ftpd_pclose(FILE *iop) * pclose returns -1 if stream is not associated with a * `popened' command, or, if already `pclosed'. */ - if (pids == 0 || pids[fdes = fileno(iop)] == 0) + if (pids == NULL || pids[fdes = fileno(iop)] == 0) return (-1); (void)fclose(iop); omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));