aboutsummaryrefslogtreecommitdiff
path: root/intl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-11-20 04:19:45 +0000
committerUlrich Drepper <drepper@redhat.com>2002-11-20 04:19:45 +0000
commit51b3c8f6b7022ea2351464d174b77dee3505274f (patch)
tree33d462107c352a793f605ae0c7ccb0c912c1bb0e /intl
parent96bbfe3f095556d3718e6b8cf65c143782efb8c3 (diff)
downloadglibc-51b3c8f6b7022ea2351464d174b77dee3505274f.zip
glibc-51b3c8f6b7022ea2351464d174b77dee3505274f.tar.gz
glibc-51b3c8f6b7022ea2351464d174b77dee3505274f.tar.bz2
(read_alias_file): Use only about 400 bytes of stack space instead of 16k.
Diffstat (limited to 'intl')
-rw-r--r--intl/localealias.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/intl/localealias.c b/intl/localealias.c
index f5d4e57..697ef8c 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -236,8 +236,10 @@ read_alias_file (fname, fname_len)
a) we are only interested in the first two fields
b) these fields must be usable as file names and so must not
be that long
- */
- char buf[BUFSIZ];
+ We avoid a multi-kilobyte buffer here since this would use up
+ stack space which we might not have if the program ran out of
+ memory. */
+ char buf[400];
char *alias;
char *value;
char *cp;
@@ -246,19 +248,6 @@ read_alias_file (fname, fname_len)
/* EOF reached. */
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;
/* Ignore leading white space. */
while (isspace ((unsigned char) cp[0]))
@@ -342,6 +331,14 @@ read_alias_file (fname, fname_len)
++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