summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/session.c b/session.c
index e72fcb0a..511fc4e8 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.297 2018/06/06 18:23:32 djm Exp $ */
+/* $OpenBSD: session.c,v 1.298 2018/06/06 18:29:18 markus Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -873,18 +873,18 @@ read_environment_file(char ***env, u_int *envsize,
const char *filename)
{
FILE *f;
- char buf[4096];
- char *cp, *value;
+ char *line = NULL, *cp, *value;
+ size_t linesize = 0;
u_int lineno = 0;
f = fopen(filename, "r");
if (!f)
return;
- while (fgets(buf, sizeof(buf), f)) {
+ while (getline(&line, &linesize, f) != -1) {
if (++lineno > 1000)
fatal("Too many lines in environment file %s", filename);
- for (cp = buf; *cp == ' ' || *cp == '\t'; cp++)
+ for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
;
if (!*cp || *cp == '#' || *cp == '\n')
continue;
@@ -905,6 +905,7 @@ read_environment_file(char ***env, u_int *envsize,
value++;
child_set_env(env, envsize, cp, value);
}
+ free(line);
fclose(f);
}