From owner-svn-src-stable@freebsd.org Fri Jul 22 14:24:19 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 60FA5BA0FB9; Fri, 22 Jul 2016 14:24:19 +0000 (UTC) (envelope-from ache@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 35953151F; Fri, 22 Jul 2016 14:24:19 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6MEOI0s025891; Fri, 22 Jul 2016 14:24:18 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6MEOHmM025885; Fri, 22 Jul 2016 14:24:17 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201607221424.u6MEOHmM025885@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Fri, 22 Jul 2016 14:24:17 +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: r303185 - in stable/10/lib/libc: gen locale regex stdio 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.22 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: Fri, 22 Jul 2016 14:24:19 -0000 Author: ache Date: Fri Jul 22 14:24:17 2016 New Revision: 303185 URL: https://svnweb.freebsd.org/changeset/base/303185 Log: MFC: r302824 1) Eliminate possibility to call __*collate_range_cmp() with inclomplete locale (which cause core dump) by removing whole 'table' argument by which it passed. 2) Restore __collate_range_cmp() in __sccl(). 3) Collating [a-z] range in regcomp() works for single byte locales only (we can't do it for other ones). In previous state only first 256 wide chars are considered and all others are just silently dropped from the range. Modified: stable/10/lib/libc/gen/fnmatch.c stable/10/lib/libc/gen/glob.c stable/10/lib/libc/locale/collate.h stable/10/lib/libc/locale/collcmp.c stable/10/lib/libc/regex/regcomp.c stable/10/lib/libc/stdio/vfscanf.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/fnmatch.c ============================================================================== --- stable/10/lib/libc/gen/fnmatch.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/gen/fnmatch.c Fri Jul 22 14:24:17 2016 (r303185) @@ -304,8 +304,8 @@ rangematch(pattern, test, flags, newp, p if (table->__collate_load_error ? c <= test && test <= c2 : - __collate_range_cmp(table, c, test) <= 0 - && __collate_range_cmp(table, test, c2) <= 0 + __wcollate_range_cmp(c, test) <= 0 + && __wcollate_range_cmp(test, c2) <= 0 ) ok = 1; } else if (c == test) Modified: stable/10/lib/libc/gen/glob.c ============================================================================== --- stable/10/lib/libc/gen/glob.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/gen/glob.c Fri Jul 22 14:24:17 2016 (r303185) @@ -836,8 +836,8 @@ match(Char *name, Char *pat, Char *paten if ((*pat & M_MASK) == M_RNG) { if (table->__collate_load_error ? CHAR(c) <= CHAR(k) && CHAR(k) <= CHAR(pat[1]) : - __collate_range_cmp(table, CHAR(c), CHAR(k)) <= 0 - && __collate_range_cmp(table, CHAR(k), CHAR(pat[1])) <= 0 + __wcollate_range_cmp(CHAR(c), CHAR(k)) <= 0 + && __wcollate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0 ) ok = 1; pat += 2; Modified: stable/10/lib/libc/locale/collate.h ============================================================================== --- stable/10/lib/libc/locale/collate.h Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/locale/collate.h Fri Jul 22 14:24:17 2016 (r303185) @@ -72,7 +72,8 @@ u_char *__collate_strdup(u_char *); u_char *__collate_substitute(struct xlocale_collate *, const u_char *); int __collate_load_tables(const char *); void __collate_lookup(struct xlocale_collate *, const u_char *, int *, int *, int *); -int __collate_range_cmp(struct xlocale_collate *, int, int); +int __collate_range_cmp(char, char); +int __wcollate_range_cmp(wchar_t, wchar_t); #ifdef COLLATE_DEBUG void __collate_print_tables(void); #endif Modified: stable/10/lib/libc/locale/collcmp.c ============================================================================== --- stable/10/lib/libc/locale/collcmp.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/locale/collcmp.c Fri Jul 22 14:24:17 2016 (r303185) @@ -33,20 +33,29 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include "collate.h" /* * Compare two characters using collate */ -int __collate_range_cmp(struct xlocale_collate *table, int c1, int c2) +int __collate_range_cmp(char c1, char c2) { static char s1[2], s2[2]; s1[0] = c1; s2[0] = c2; - struct _xlocale l = {{0}}; - l.components[XLC_COLLATE] = (struct xlocale_component *)table; - return (strcoll_l(s1, s2, &l)); + return (strcoll(s1, s2)); +} + +int __wcollate_range_cmp(wchar_t c1, wchar_t c2) +{ + wchar_t s1[2], s2[2]; + + s1[0] = c1; + s1[1] = L'\0'; + s2[0] = c2; + s2[1] = L'\0'; + return (wcscoll(s1, s2)); } Modified: stable/10/lib/libc/regex/regcomp.c ============================================================================== --- stable/10/lib/libc/regex/regcomp.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/regex/regcomp.c Fri Jul 22 14:24:17 2016 (r303185) @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -817,14 +816,14 @@ p_b_term(struct parse *p, cset *cs) if (start == finish) CHadd(p, cs, start); else { - if (table->__collate_load_error) { - (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE); + if (table->__collate_load_error || MB_CUR_MAX > 1) { + (void)REQUIRE(start <= finish, REG_ERANGE); CHaddrange(p, cs, start, finish); } else { - (void)REQUIRE(__collate_range_cmp(table, start, finish) <= 0, REG_ERANGE); + (void)REQUIRE(__wcollate_range_cmp(start, finish) <= 0, REG_ERANGE); for (i = 0; i <= UCHAR_MAX; i++) { - if ( __collate_range_cmp(table, start, i) <= 0 - && __collate_range_cmp(table, i, finish) <= 0 + if ( __wcollate_range_cmp(start, i) <= 0 + && __wcollate_range_cmp(i, finish) <= 0 ) CHadd(p, cs, i); } Modified: stable/10/lib/libc/stdio/vfscanf.c ============================================================================== --- stable/10/lib/libc/stdio/vfscanf.c Fri Jul 22 12:55:31 2016 (r303184) +++ stable/10/lib/libc/stdio/vfscanf.c Fri Jul 22 14:24:17 2016 (r303185) @@ -873,7 +873,7 @@ doswitch: n = *fmt; if (n == ']' || (table->__collate_load_error ? n < c : - __collate_range_cmp (table, n, c) < 0 + __collate_range_cmp(n, c) < 0 ) ) { c = '-'; @@ -887,8 +887,8 @@ doswitch: } while (c < n); } else { for (i = 0; i < 256; i ++) - if ( __collate_range_cmp (table, c, i) < 0 - && __collate_range_cmp (table, i, n) <= 0 + if (__collate_range_cmp(c, i) <= 0 && + __collate_range_cmp(i, n) <= 0 ) tab[i] = v; }