summaryrefslogtreecommitdiff
path: root/libc/locale
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-12-02 17:19:10 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-12-02 17:19:10 +0000
commit207e6eacd86cbc50bc1f78b06709b93a085dd9d8 (patch)
tree9abd9f8a20beb2f95b34e1e5a16c501dc87fcfcf /libc/locale
parent709390fe0688830722a221c3d8a49a85855f7232 (diff)
Merge changes between r15868 and r16068 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@16069 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/locale')
-rw-r--r--libc/locale/weight.h11
-rw-r--r--libc/locale/weightwc.h9
2 files changed, 11 insertions, 9 deletions
diff --git a/libc/locale/weight.h b/libc/locale/weight.h
index dc70a00be..967e176ca 100644
--- a/libc/locale/weight.h
+++ b/libc/locale/weight.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2003,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,1999,2000,2003,2004,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper, <drepper@cygnus.com>.
@@ -20,7 +20,7 @@
/* Find index of weight. */
auto inline int32_t
__attribute ((always_inline))
-findidx (const unsigned char **cpp)
+findidx (const unsigned char **cpp, size_t len)
{
int_fast32_t i = table[*(*cpp)++];
const unsigned char *cp;
@@ -34,6 +34,7 @@ findidx (const unsigned char **cpp)
Search for the correct one. */
cp = &extra[-i];
usrc = *cpp;
+ --len;
while (1)
{
size_t nhere;
@@ -56,7 +57,7 @@ findidx (const unsigned char **cpp)
already. */
size_t cnt;
- for (cnt = 0; cnt < nhere; ++cnt)
+ for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
if (cp[cnt] != usrc[cnt])
break;
@@ -79,13 +80,13 @@ findidx (const unsigned char **cpp)
size_t cnt;
size_t offset = 0;
- for (cnt = 0; cnt < nhere; ++cnt)
+ for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
if (cp[cnt] != usrc[cnt])
break;
if (cnt != nhere)
{
- if (cp[cnt] > usrc[cnt])
+ if (cnt == len || cp[cnt] > usrc[cnt])
{
/* Cannot be in this range. */
cp += 2 * nhere;
diff --git a/libc/locale/weightwc.h b/libc/locale/weightwc.h
index 9ea1126a2..786209142 100644
--- a/libc/locale/weightwc.h
+++ b/libc/locale/weightwc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001,2003,2004,2005,2007 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2001,2003,2004,2005,2007,2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Ulrich Drepper, <drepper@cygnus.com>.
@@ -20,7 +20,7 @@
/* Find index of weight. */
auto inline int32_t
__attribute ((always_inline))
-findidx (const wint_t **cpp)
+findidx (const wint_t **cpp, size_t len)
{
wint_t ch = *(*cpp)++;
int32_t i = __collidx_table_lookup ((const char *) table, ch);
@@ -32,6 +32,7 @@ findidx (const wint_t **cpp)
/* Oh well, more than one sequence starting with this byte.
Search for the correct one. */
const int32_t *cp = (const int32_t *) &extra[-i];
+ --len;
while (1)
{
size_t nhere;
@@ -54,7 +55,7 @@ findidx (const wint_t **cpp)
already. */
size_t cnt;
- for (cnt = 0; cnt < nhere; ++cnt)
+ for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
if (cp[cnt] != usrc[cnt])
break;
@@ -75,7 +76,7 @@ findidx (const wint_t **cpp)
size_t cnt;
size_t offset;
- for (cnt = 0; cnt < nhere - 1; ++cnt)
+ for (cnt = 0; cnt < nhere - 1 && cnt < len; ++cnt)
if (cp[cnt] != usrc[cnt])
break;