summaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-05-18 17:49:41 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-05-18 17:49:41 +0000
commiteee4dee3355eabdf7821f22032090067af27a5ad (patch)
treea356b63a14463b2f7724655abdfa746f312c9e60 /gcc/cpplib.c
parent52e66d5637c35159aa82d7316ad3c19cc641168e (diff)
downloadgcc-eee4dee3355eabdf7821f22032090067af27a5ad.tar.gz
(safe_read): If MAX_READ_LEN is defined, limit incremental read
attempts to that amount. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@14093 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 10dc2fc1d09..50ef8caae34 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -7197,7 +7197,8 @@ file_size_and_mode (fd, mode_pointer, size_pointer)
}
/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
- retrying if necessary. Return a negative value if an error occurs,
+ retrying if necessary. If MAX_READ_LEN is defined, read at most
+ that bytes at a time. Return a negative value if an error occurs,
otherwise return the actual number of bytes read,
which must be LEN unless end-of-file was reached. */
@@ -7207,9 +7208,16 @@ safe_read (desc, ptr, len)
char *ptr;
int len;
{
- int left = len;
+ int left, rcount, nchars;
+
+ left = len;
while (left > 0) {
- int nchars = read (desc, ptr, left);
+ rcount = left;
+#ifdef MAX_READ_LEN
+ if (rcount > MAX_READ_LEN)
+ rcount = MAX_READ_LEN;
+#endif
+ nchars = read (desc, ptr, rcount);
if (nchars < 0)
{
#ifdef EINTR