From owner-svn-src-stable@freebsd.org Sat Dec 3 16:52:41 2016 Return-Path: Delivered-To: svn-src-stable@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 ADD2BC651DB; Sat, 3 Dec 2016 16:52:41 +0000 (UTC) (envelope-from ngie@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 6E8AFBBC; Sat, 3 Dec 2016 16:52:41 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB3GqevX002705; Sat, 3 Dec 2016 16:52:40 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB3Gqen1002702; Sat, 3 Dec 2016 16:52:40 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612031652.uB3Gqen1002702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 3 Dec 2016 16:52:40 +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: r309482 - in stable/10: etc/mtree lib/libc/iconv lib/libc/tests lib/libc/tests/iconv X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2016 16:52:41 -0000 Author: ngie Date: Sat Dec 3 16:52:40 2016 New Revision: 309482 URL: https://svnweb.freebsd.org/changeset/base/309482 Log: MFC r299704: r299704 (by vangyzen): iconvctl(3): remove superfluous NULL pointer tests convname and dst are guaranteed to be non-NULL by iconv_open(3). src is an array. Remove these tests for NULL pointers. While I'm here, eliminate a strlcpy with a correct but suspicious-looking calculation for the third parameter (i.e. not a simple sizeof). Compare the strings in-place instead of copying. Found by: bdrewery Found by: Coverity CID: 1130050, 1130056 Added: stable/10/lib/libc/tests/iconv/ - copied from r299704, head/lib/libc/tests/iconv/ Modified: stable/10/etc/mtree/BSD.tests.dist stable/10/lib/libc/iconv/bsd_iconv.c stable/10/lib/libc/tests/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/mtree/BSD.tests.dist ============================================================================== --- stable/10/etc/mtree/BSD.tests.dist Sat Dec 3 16:02:53 2016 (r309481) +++ stable/10/etc/mtree/BSD.tests.dist Sat Dec 3 16:52:40 2016 (r309482) @@ -99,6 +99,8 @@ data .. .. + iconv + .. inet .. locale Modified: stable/10/lib/libc/iconv/bsd_iconv.c ============================================================================== --- stable/10/lib/libc/iconv/bsd_iconv.c Sat Dec 3 16:02:53 2016 (r309481) +++ stable/10/lib/libc/iconv/bsd_iconv.c Sat Dec 3 16:52:40 2016 (r309482) @@ -259,8 +259,9 @@ __bsd_iconvctl(iconv_t cd, int request, struct _citrus_iconv *cv; struct iconv_hooks *hooks; const char *convname; - char src[PATH_MAX], *dst; + char *dst; int *i; + size_t srclen; cv = (struct _citrus_iconv *)(void *)cd; hooks = (struct iconv_hooks *)argument; @@ -275,12 +276,9 @@ __bsd_iconvctl(iconv_t cd, int request, case ICONV_TRIVIALP: convname = cv->cv_shared->ci_convname; dst = strchr(convname, '/'); - - strlcpy(src, convname, dst - convname + 1); + srclen = dst - convname; dst++; - if ((convname == NULL) || (src == NULL) || (dst == NULL)) - return (-1); - *i = strcmp(src, dst) == 0 ? 1 : 0; + *i = (srclen == strlen(dst)) && !memcmp(convname, dst, srclen); return (0); case ICONV_GET_TRANSLITERATE: *i = 1; Modified: stable/10/lib/libc/tests/Makefile ============================================================================== --- stable/10/lib/libc/tests/Makefile Sat Dec 3 16:02:53 2016 (r309481) +++ stable/10/lib/libc/tests/Makefile Sat Dec 3 16:52:40 2016 (r309482) @@ -10,6 +10,7 @@ TESTS_SUBDIRS= c063 TESTS_SUBDIRS+= db TESTS_SUBDIRS+= gen TESTS_SUBDIRS+= hash +TESTS_SUBDIRS+= iconv TESTS_SUBDIRS+= inet TESTS_SUBDIRS+= net TESTS_SUBDIRS+= nss