|
|
00db10 |
commit 27572ef96a66b61f5a6d81196c05983ab3dc9994
|
|
|
00db10 |
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
|
|
|
00db10 |
Date: Sun Jun 30 20:45:19 2013 +0530
|
|
|
00db10 |
|
|
|
00db10 |
Check for integer overflow
|
|
|
00db10 |
|
|
|
00db10 |
diff --git glibc-2.17-c758a686/string/strcoll_l.c glibc-2.17-c758a686/string/strcoll_l.c
|
|
|
00db10 |
index 1be6874..cbe5962 100644
|
|
|
00db10 |
--- glibc-2.17-c758a686/string/strcoll_l.c
|
|
|
00db10 |
+++ glibc-2.17-c758a686/string/strcoll_l.c
|
|
|
00db10 |
@@ -524,6 +524,14 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
|
|
|
00db10 |
memset (&seq1, 0, sizeof (seq1));
|
|
|
00db10 |
seq2 = seq1;
|
|
|
00db10 |
|
|
|
00db10 |
+ size_t size_max = SIZE_MAX / (sizeof (int32_t) + 1);
|
|
|
00db10 |
+
|
|
|
00db10 |
+ /* If the strings are long enough to cause overflow in the size request, then
|
|
|
00db10 |
+ skip the allocation and proceed with the non-cached routines. */
|
|
|
00db10 |
+ if (MIN (s1len, s2len) > size_max
|
|
|
00db10 |
+ || MAX (s1len, s2len) > size_max - MIN (s1len, s2len))
|
|
|
00db10 |
+ goto begin_collate;
|
|
|
00db10 |
+
|
|
|
00db10 |
if (! __libc_use_alloca ((s1len + s2len) * (sizeof (int32_t) + 1)))
|
|
|
00db10 |
{
|
|
|
00db10 |
seq1.idxarr = (int32_t *) malloc ((s1len + s2len) * (sizeof (int32_t) + 1));
|
|
|
00db10 |
@@ -546,8 +554,10 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l)
|
|
|
00db10 |
seq2.rulearr = (unsigned char *) alloca (s2len);
|
|
|
00db10 |
}
|
|
|
00db10 |
|
|
|
00db10 |
- int rule = 0;
|
|
|
00db10 |
+ int rule;
|
|
|
00db10 |
|
|
|
00db10 |
+ begin_collate:
|
|
|
00db10 |
+ rule = 0;
|
|
|
00db10 |
/* Cache values in the first pass and if needed, use them in subsequent
|
|
|
00db10 |
passes. */
|
|
|
00db10 |
for (int pass = 0; pass < nrules; ++pass)
|