2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Add line continuation support to sudo_parseln() and make it use

getline() instead of fgets() internally.
This commit is contained in:
Todd C. Miller
2013-02-07 10:56:01 -05:00
parent 2d6095420a
commit 7aae6bd6e3
21 changed files with 418 additions and 60 deletions

View File

@@ -1029,15 +1029,15 @@ void
read_env_file(const char *path, int overwrite)
{
FILE *fp;
char *cp, *var, *val;
size_t var_len, val_len;
char *cp, *var, *val, *line = NULL;
size_t var_len, val_len, linesize = 0;
if ((fp = fopen(path, "r")) == NULL)
return;
while ((var = sudo_parseln(fp)) != NULL) {
while (sudo_parseln(&line, &linesize, NULL, fp) != -1) {
/* Skip blank or comment lines */
if (*var == '\0')
if (*(var = line) == '\0')
continue;
/* Skip optional "export " */
@@ -1069,6 +1069,7 @@ read_env_file(const char *path, int overwrite)
sudo_putenv(cp, true, overwrite);
}
free(line);
fclose(fp);
}