From owner-svn-src-stable-11@freebsd.org Sun Oct 9 19:57:22 2016 Return-Path: Delivered-To: svn-src-stable-11@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 76BD4C0B253; Sun, 9 Oct 2016 19:57: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 3864263B; Sun, 9 Oct 2016 19:57: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 u99JvLI8086678; Sun, 9 Oct 2016 19:57:21 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99JvLmP086675; Sun, 9 Oct 2016 19:57:21 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610091957.u99JvLmP086675@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 19:57:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306909 - stable/11/usr.sbin/fifolog/lib X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 19:57:22 -0000 Author: pfg Date: Sun Oct 9 19:57:20 2016 New Revision: 306909 URL: https://svnweb.freebsd.org/changeset/base/306909 Log: MFC r305812: fifolog(1): invert order of calloc(3) arguments. The second argument to calloc(3) should be the size, make it so. While here be a little bit more cautious in fifolog_reader_open() to protect in the unlikely event of an overflowed allocation. Modified: stable/11/usr.sbin/fifolog/lib/fifolog_create.c stable/11/usr.sbin/fifolog/lib/fifolog_reader.c stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c stable/11/usr.sbin/fifolog/lib/miniobj.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/fifolog/lib/fifolog_create.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 19:57:20 2016 (r306909) @@ -97,7 +97,7 @@ fifolog_create(const char *fn, off_t siz if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0) return ("Could not ftrunc"); - buf = calloc(recsize, 1); + buf = calloc(1, recsize); if (buf == NULL) return ("Could not malloc"); Modified: stable/11/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 19:57:20 2016 (r306909) @@ -67,10 +67,10 @@ fifolog_reader_open(const char *fname) if (retval != NULL) err(1, "%s", retval); - fr->olen = fr->ff->recsize * 16; - fr->obuf = calloc(fr->olen, 1); + fr->obuf = calloc(16, fr->ff->recsize); if (fr->obuf == NULL) err(1, "Cannot malloc"); + fr->olen = fr->ff->recsize * 16; i = inflateInit(fr->ff->zs); assert(i == Z_OK); Modified: stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 19:57:20 2016 (r306909) @@ -45,7 +45,7 @@ static int fifolog_write_gzip(struct fifolog_writer *f, time_t now); #define ALLOC(ptr, size) do { \ - (*(ptr)) = calloc(size, 1); \ + (*(ptr)) = calloc(1, size); \ assert(*(ptr) != NULL); \ } while (0) Modified: stable/11/usr.sbin/fifolog/lib/miniobj.h ============================================================================== --- stable/11/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 19:57:20 2016 (r306909) @@ -28,7 +28,7 @@ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0)