From owner-svn-src-stable-11@freebsd.org Tue May 9 23:31:11 2017 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 5CF3CD666FF; Tue, 9 May 2017 23:31:11 +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 3798FB86; Tue, 9 May 2017 23:31:11 +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 v49NVATg013101; Tue, 9 May 2017 23:31:10 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v49NV9an013096; Tue, 9 May 2017 23:31:09 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201705092331.v49NV9an013096@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 9 May 2017 23:31:09 +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: r318121 - in stable/11/lib: libgssapi libiconv_modules/ISO2022 libutil 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: Tue, 09 May 2017 23:31:11 -0000 Author: pfg Date: Tue May 9 23:31:09 2017 New Revision: 318121 URL: https://svnweb.freebsd.org/changeset/base/318121 Log: MFC r317265: lib: initial use of reallocarray(3). Make some use of reallocarray, attempting to limit it to cases where the parameters are unsigned and there is some theoretical chance of overflow. Modified: stable/11/lib/libgssapi/gss_buffer_set.c stable/11/lib/libiconv_modules/ISO2022/citrus_iso2022.c stable/11/lib/libutil/gr_util.c stable/11/lib/libutil/login_cap.c stable/11/lib/libutil/pw_util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libgssapi/gss_buffer_set.c ============================================================================== --- stable/11/lib/libgssapi/gss_buffer_set.c Tue May 9 23:28:42 2017 (r318120) +++ stable/11/lib/libgssapi/gss_buffer_set.c Tue May 9 23:31:09 2017 (r318121) @@ -76,8 +76,8 @@ gss_add_buffer_set_member(OM_uint32 * mi } set = *buffer_set; - set->elements = realloc(set->elements, - (set->count + 1) * sizeof(set->elements[0])); + set->elements = reallocarray(set->elements, set->count + 1, + sizeof(set->elements[0])); if (set->elements == NULL) { *minor_status = ENOMEM; return (GSS_S_FAILURE); Modified: stable/11/lib/libiconv_modules/ISO2022/citrus_iso2022.c ============================================================================== --- stable/11/lib/libiconv_modules/ISO2022/citrus_iso2022.c Tue May 9 23:28:42 2017 (r318120) +++ stable/11/lib/libiconv_modules/ISO2022/citrus_iso2022.c Tue May 9 23:31:09 2017 (r318121) @@ -259,8 +259,8 @@ get_recommend(_ISO2022EncodingInfo * __r if (!ei->recommend[i]) ei->recommend[i] = malloc(sizeof(_ISO2022Charset)); else { - p = realloc(ei->recommend[i], - sizeof(_ISO2022Charset) * (ei->recommendsize[i] + 1)); + p = reallocarray(ei->recommend[i], ei->recommendsize[i] + 1, + sizeof(_ISO2022Charset)); if (!p) return (_PARSEFAIL); ei->recommend[i] = p; Modified: stable/11/lib/libutil/gr_util.c ============================================================================== --- stable/11/lib/libutil/gr_util.c Tue May 9 23:28:42 2017 (r318120) +++ stable/11/lib/libutil/gr_util.c Tue May 9 23:31:09 2017 (r318121) @@ -205,7 +205,7 @@ gr_copy(int ffd, int tfd, const struct g if (eof) break; while ((size_t)(q - p) >= size) { - if ((tmp = realloc(buf, size * 2)) == NULL) { + if ((tmp = reallocarray(buf, 2, size)) == NULL) { warnx("group line too long"); goto err; } Modified: stable/11/lib/libutil/login_cap.c ============================================================================== --- stable/11/lib/libutil/login_cap.c Tue May 9 23:28:42 2017 (r318120) +++ stable/11/lib/libutil/login_cap.c Tue May 9 23:31:09 2017 (r318121) @@ -86,7 +86,7 @@ allocarray(size_t sz) if (sz <= internal_arraysz) p = internal_array; - else if ((p = realloc(internal_array, sz * sizeof(char*))) != NULL) { + else if ((p = reallocarray(internal_array, sz, sizeof(char*))) != NULL) { internal_arraysz = sz; internal_array = p; } Modified: stable/11/lib/libutil/pw_util.c ============================================================================== --- stable/11/lib/libutil/pw_util.c Tue May 9 23:28:42 2017 (r318120) +++ stable/11/lib/libutil/pw_util.c Tue May 9 23:31:09 2017 (r318121) @@ -468,7 +468,7 @@ pw_copy(int ffd, int tfd, const struct p if (eof) break; while ((size_t)(q - p) >= size) { - if ((tmp = realloc(buf, size * 2)) == NULL) { + if ((tmp = reallocarray(buf, 2, size)) == NULL) { warnx("passwd line too long"); goto err; }