This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

[patch,libgfortran] PR27575 gfortran - does not generate error when trying to read too much data


:ADDPATCH fortran:

Its amazing how long we have gone and did not see this. In the case in the PR we have no bytes left after the first read so we don't try to read anything, which is harmless. But, we don't give an error either. This fix adds the error.

The attached patch I think can fall under the obvious and simple rule and I will commit in a few days to trunk and a few days later to 4.1 branch. (unless comments or objections)

Regression tested and NIST tested OK.

Best Regards,

Jerry

2006-05-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/27575
	* io/transfer.c (read_block):  Add check for end file condition.
	(read_block_direct): Add check for end file condition.
Index: io/transfer.c
===================================================================
*** io/transfer.c	(revision 113642)
--- io/transfer.c	(working copy)
*************** read_block (st_parameter_dt *dtp, int *l
*** 272,277 ****
--- 272,284 ----
  	    }
  	}
  
+       if (dtp->u.p.current_unit->bytes_left == 0)
+ 	{
+ 	  dtp->u.p.current_unit->endfile = AT_ENDFILE;
+ 	  generate_error (&dtp->common, ERROR_END, NULL);
+ 	  return;
+ 	}
+ 
        *length = dtp->u.p.current_unit->bytes_left;
      }
  
*************** read_block_direct (st_parameter_dt *dtp,
*** 328,333 ****
--- 335,347 ----
  	    }
  	}
  
+       if (dtp->u.p.current_unit->bytes_left == 0)
+ 	{
+ 	  dtp->u.p.current_unit->endfile = AT_ENDFILE;
+ 	  generate_error (&dtp->common, ERROR_END, NULL);
+ 	  return;
+ 	}
+ 
        *nbytes = dtp->u.p.current_unit->bytes_left;
      }
  

Attachment: read_eof_4.f90
Description: application/extension-f90


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