This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: problem in g77 inqure


yoshinari.hayato@kek.jp wrote:

 I've experienced a problem in using inqure statement.
If the length of the filename is larger than 256,
the buffer overrun will occurr in the function
f_inqu(libf2c/libI77/inquire.c).

 I'm not sure it's good or not but I attach my personal
fix.(This fix will discard some characters if the string 
for the filename is too long.)

diff ./inquire.c inquire.c.new
23,24c23,26
<       {       byfile=1;
<               g_char(a->infile,a->infilen,buf);
---
>       {       int actual_len;
>               actual_len = (a->infilen>255)?256:a->infilen;
>               byfile=1;
>               g_char(a->infile,actual_len,buf);

(Same kind of problem occurs in open statement.)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Thanks for your bug report - I'll talk to David Gay about it 
(he's the maintainer of the libf2c library) after checking
that it still fails with the newest version of it.

The best solution seems to be to `malloc' buf, instead of it
being an automatic variable of size 256 bytes.

I hope I'll find some time this weekend ....

Cheers, and thanks,
Toon Moene.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]