diff options
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: session.c,v 1.297 2018/06/06 18:23:32 djm Exp $ */ | 1 | /* $OpenBSD: session.c,v 1.298 2018/06/06 18:29:18 markus Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
4 | * All rights reserved | 4 | * All rights reserved |
@@ -873,18 +873,18 @@ read_environment_file(char ***env, u_int *envsize, | |||
873 | const char *filename) | 873 | const char *filename) |
874 | { | 874 | { |
875 | FILE *f; | 875 | FILE *f; |
876 | char buf[4096]; | 876 | char *line = NULL, *cp, *value; |
877 | char *cp, *value; | 877 | size_t linesize = 0; |
878 | u_int lineno = 0; | 878 | u_int lineno = 0; |
879 | 879 | ||
880 | f = fopen(filename, "r"); | 880 | f = fopen(filename, "r"); |
881 | if (!f) | 881 | if (!f) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | while (fgets(buf, sizeof(buf), f)) { | 884 | while (getline(&line, &linesize, f) != -1) { |
885 | if (++lineno > 1000) | 885 | if (++lineno > 1000) |
886 | fatal("Too many lines in environment file %s", filename); | 886 | fatal("Too many lines in environment file %s", filename); |
887 | for (cp = buf; *cp == ' ' || *cp == '\t'; cp++) | 887 | for (cp = line; *cp == ' ' || *cp == '\t'; cp++) |
888 | ; | 888 | ; |
889 | if (!*cp || *cp == '#' || *cp == '\n') | 889 | if (!*cp || *cp == '#' || *cp == '\n') |
890 | continue; | 890 | continue; |
@@ -905,6 +905,7 @@ read_environment_file(char ***env, u_int *envsize, | |||
905 | value++; | 905 | value++; |
906 | child_set_env(env, envsize, cp, value); | 906 | child_set_env(env, envsize, cp, value); |
907 | } | 907 | } |
908 | free(line); | ||
908 | fclose(f); | 909 | fclose(f); |
909 | } | 910 | } |
910 | 911 | ||