mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 08:11:08 +00:00
(read_alias_file): Use only about 400 bytes of stack space instead of 16k.
This commit is contained in:
parent
96bbfe3f09
commit
51b3c8f6b7
@ -236,8 +236,10 @@ read_alias_file (fname, fname_len)
|
|||||||
a) we are only interested in the first two fields
|
a) we are only interested in the first two fields
|
||||||
b) these fields must be usable as file names and so must not
|
b) these fields must be usable as file names and so must not
|
||||||
be that long
|
be that long
|
||||||
*/
|
We avoid a multi-kilobyte buffer here since this would use up
|
||||||
char buf[BUFSIZ];
|
stack space which we might not have if the program ran out of
|
||||||
|
memory. */
|
||||||
|
char buf[400];
|
||||||
char *alias;
|
char *alias;
|
||||||
char *value;
|
char *value;
|
||||||
char *cp;
|
char *cp;
|
||||||
@ -246,19 +248,6 @@ read_alias_file (fname, fname_len)
|
|||||||
/* EOF reached. */
|
/* EOF reached. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Possibly not the whole line fits into the buffer. Ignore
|
|
||||||
the rest of the line. */
|
|
||||||
if (strchr (buf, '\n') == NULL)
|
|
||||||
{
|
|
||||||
char altbuf[BUFSIZ];
|
|
||||||
do
|
|
||||||
if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
|
|
||||||
/* Make sure the inner loop will be left. The outer loop
|
|
||||||
will exit at the `feof' test. */
|
|
||||||
break;
|
|
||||||
while (strchr (altbuf, '\n') == NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
cp = buf;
|
cp = buf;
|
||||||
/* Ignore leading white space. */
|
/* Ignore leading white space. */
|
||||||
while (isspace ((unsigned char) cp[0]))
|
while (isspace ((unsigned char) cp[0]))
|
||||||
@ -342,6 +331,14 @@ read_alias_file (fname, fname_len)
|
|||||||
++added;
|
++added;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Possibly not the whole line fits into the buffer. Ignore
|
||||||
|
the rest of the line. */
|
||||||
|
while (strchr (buf, '\n') == NULL)
|
||||||
|
if (FGETS (buf, sizeof buf, fp) == NULL)
|
||||||
|
/* Make sure the inner loop will be left. The outer loop
|
||||||
|
will exit at the `feof' test. */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should we test for ferror()? I think we have to silently ignore
|
/* Should we test for ferror()? I think we have to silently ignore
|
||||||
|
Loading…
Reference in New Issue
Block a user