public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14547] New: strcoll integer / buffer overflow
@ 2012-09-05 20:59 jsm28 at gcc dot gnu.org
  2012-09-05 21:13 ` [Bug libc/14547] " jsm28 at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-09-05 20:59 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14547

             Bug #: 14547
           Summary: strcoll integer / buffer overflow
           Product: glibc
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jsm28@gcc.gnu.org
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


The code in string/strcoll_l.c that computes a memory allocation size as (s1len
+ s2len) * (sizeof (int32_t) + 1) fails to allow for possible integer overflow
in this computation.  On a 32-bit host this can cause too-small allocations and
consequent buffer overflow if the strings total more than 0.8GB.  Testcase:

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 429496730

int
main (void)
{
  char *p = malloc (1 + SIZE);
  if (setlocale (LC_COLLATE, "en_GB.UTF-8") == NULL)
    {
      puts ("setlocale failed, cannot test for overflow");
      return 0;
    }
  if (p == NULL)
    {
      puts ("malloc failed, cannot test for overflow");
      return 0;
    }
  memset (p, 'x', SIZE);
  p[SIZE] = 0;
  printf ("%d\n", strcoll (p, p));
  return 0;
}

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-02-24 11:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-05 20:59 [Bug libc/14547] New: strcoll integer / buffer overflow jsm28 at gcc dot gnu.org
2012-09-05 21:13 ` [Bug libc/14547] " jsm28 at gcc dot gnu.org
2012-09-06 16:55 ` jsm28 at gcc dot gnu.org
2012-09-06 17:03 ` ppluzhnikov at google dot com
2012-09-08  3:38 ` bugdal at aerifal dot cx
2012-09-11  9:53 ` shaun.colley at ioactive dot com
2012-09-11 15:52 ` shaun.colley at ioactive dot com
2013-09-23  6:00 ` siddhesh at redhat dot com
2013-10-25 13:10 ` mancha1 at hush dot com
2013-10-25 13:17 ` mancha1 at hush dot com
2013-10-25 13:30 ` siddhesh at redhat dot com
2013-10-25 15:03 ` mancha1 at hush dot com
2014-02-16 19:41 ` jackie.rosen at hushmail dot com
2014-05-28 19:41 ` schwab at sourceware dot org
2014-06-13 10:47 ` fweimer at redhat dot com
2014-06-13 11:43 ` [Bug libc/14547] strcoll integer / buffer overflow (CVE-2012-4412, CVE-2012-4424) fweimer at redhat dot com
2015-02-24 11:36 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).