public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/62188] New: Array bounds overrun in bessel_yn_r4/8/16 and other functions
@ 2014-08-19 13:48 vogt at linux dot vnet.ibm.com
  2014-08-19 16:54 ` [Bug libfortran/62188] " kargl at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: vogt at linux dot vnet.ibm.com @ 2014-08-19 13:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62188

            Bug ID: 62188
           Summary: Array bounds overrun in bessel_yn_r4/8/16 and other
                    functions
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vogt at linux dot vnet.ibm.com

There's an array bounds overrun in
gfortran/generated/bessel_r4.c:bessel_yn_r4().  The function is passed the
arguments n1 and n2 (n1 <= n2) and allocates memory for (n2 - n1 + 1) result
values:

  size_t size = n2 < n1 ? 0 : n2-n1+1;
  ...
  ret->base_addr = xmallocarray (size, sizeof (GFC_REAL_4));

But later on it writes from index 0 to n1 + n2:

  for (...; i <= n1+n2; ...)
    ...          ^^^^^
    ret->base_addr[i*stride] = ...;

The loop should be

  for (i = 2; i < n2-n1; i++)

instead.  The same bug exists in bessel_r8.c and bessel_r16.c and has been
present since at least gcc-4.8.  The existing test cases (bessel_<n>.f90) all
use 0 or low values > 0, so they have not caught this bug yet.


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

end of thread, other threads:[~2014-08-26 18:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19 13:48 [Bug libfortran/62188] New: Array bounds overrun in bessel_yn_r4/8/16 and other functions vogt at linux dot vnet.ibm.com
2014-08-19 16:54 ` [Bug libfortran/62188] " kargl at gcc dot gnu.org
2014-08-20  7:03 ` vogt at linux dot vnet.ibm.com
2014-08-20 16:19 ` kargl at gcc dot gnu.org
2014-08-20 16:22 ` kargl at gcc dot gnu.org
2014-08-20 16:24 ` kargl at gcc dot gnu.org
2014-08-20 16:30 ` kargl at gcc dot gnu.org
2014-08-26 13:08 ` burnus at gcc dot gnu.org
2014-08-26 14:52 ` sgk at troutmask dot apl.washington.edu
2014-08-26 17:54 ` sgk at troutmask dot apl.washington.edu
2014-08-26 18:14 ` sgk at troutmask dot apl.washington.edu

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).