static analysis: buffer overflow

static analysis: buffer overflow

bealeja's picture

Hello all,

The following error is generated by a static analysis of my application:

error #12048: buffer overflow: array index of "DESIND" is outside the bounds; array "DESIND" of size (1:5) is indexed by value 0

This error refers to the following file where DESIND is declared as:

CHARACTER*6  DESIND

and the offending line is:

DESIND ='IALFA'

Is this really a buffer overflow?  If so, how so?

Thanks,

Jim

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Steve Lionel (Intel)'s picture

Would you please show a small but complete program that demonstrates this message? I'm unable to reproduce it based on your description.
 

Steve
bealeja's picture

Hi Steve!

The program is very simple:

PROGRAM CONSOLE1

   CHARACTER*6 DESIND
   
   DESIND = '123456'
   DESIND = '12345'
   DESIND = '1234'
   
END PROGRAM

The command line is as follow:

/nologo /debug:full /Od /Qdiag-enable:sc2 /Qdiag-enable:sc-full /Qdiag-enable:sc-include /Qdiag-enable:sc-single-file /warn:interfaces /module:"Debug\\" /object:"Debug\\" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c

and the static analysis output (if you can find the pdr file!) contains,

Main.f90(6): error #12048: buffer overflow: array index of "DESIND" is outside the bounds; array "DESIND" of size (1:5) is indexed by value 0

I played around with it a little bit.  The above seems to be the simplest case that generates the error message.  

It is weird!  I don't understand it at all.

Thanks!

Jim

Steve Lionel (Intel)'s picture

It's a bug - I will report it.

Steve

Login to leave a comment.