bool sudoers_warnings = true;
bool parse_error = false;
int errorlineno = -1;
-const char *errorfile = NULL;
+char *errorfile = NULL;
struct defaults_list defaults = TAILQ_HEAD_INITIALIZER(defaults);
struct userspec_list userspecs = TAILQ_HEAD_INITIALIZER(userspecs);
/* Save the line the first error occurred on. */
if (errorlineno == -1) {
errorlineno = sudolineno;
- errorfile = sudoers;
+ free(errorfile);
+ errorfile = strdup(sudoers);
+ if (errorfile == NULL)
+ sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+ "unable to allocate memory");
}
if (sudoers_warnings && s != NULL) {
LEXTRACE("<*> ");
parse_error = false;
errorlineno = -1;
- errorfile = sudoers;
+ free(errorfile);
+ errorfile = NULL;
sudoers_warnings = !quiet;
debug_return_bool(ret);
}
-#line 939 "gram.c"
+#line 944 "gram.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || defined(__STDC__)
static int yygrowstack(void)
}
}
break;
-#line 2032 "gram.c"
+#line 2037 "gram.c"
}
yyssp -= yym;
yystate = *yyssp;
bool sudoers_warnings = true;
bool parse_error = false;
int errorlineno = -1;
-const char *errorfile = NULL;
+char *errorfile = NULL;
struct defaults_list defaults = TAILQ_HEAD_INITIALIZER(defaults);
struct userspec_list userspecs = TAILQ_HEAD_INITIALIZER(userspecs);
/* Save the line the first error occurred on. */
if (errorlineno == -1) {
errorlineno = sudolineno;
- errorfile = sudoers;
+ free(errorfile);
+ errorfile = strdup(sudoers);
+ if (errorfile == NULL)
+ sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+ "unable to allocate memory");
}
if (sudoers_warnings && s != NULL) {
LEXTRACE("<*> ");
parse_error = false;
errorlineno = -1;
- errorfile = sudoers;
+ free(errorfile);
+ errorfile = NULL;
sudoers_warnings = !quiet;
debug_return_bool(ret);
/* gram.y */
int sudoersparse(void);
extern char *login_style;
-extern const char *errorfile;
+extern char *errorfile;
extern int errorlineno;
extern bool parse_error;
extern bool sudoers_warnings;
sudo_warnx(U_("unabled to parse temporary file (%s), unknown error"),
sp->tpath);
parse_error = true;
- errorfile = sp->path;
+ free(errorfile);
+ if ((errorfile = strdup(sp->path)) == NULL)
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
fclose(sudoersin);
if (!parse_error) {
if (!check_defaults(SETDEF_ALL, quiet) ||
check_aliases(strict, quiet) != 0) {
parse_error = true;
- errorfile = NULL;
+ free(errorfile);
+ errorfile = NULL; /* don't know which file */
}
}
sudoers_setlocale(oldlocale, NULL);
if (!quiet)
sudo_warnx(U_("failed to parse %s file, unknown error"), sudoers_file);
parse_error = true;
- errorfile = sudoers_file;
+ free(errorfile);
+ if ((errorfile = strdup(sudoers_file)) == NULL)
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
if (!parse_error) {
(void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER, true);
if (!check_defaults(SETDEF_ALL, quiet) ||
check_aliases(strict, quiet) != 0) {
parse_error = true;
- errorfile = NULL;
+ free(errorfile);
+ errorfile = NULL; /* don't know which file */
}
}
sudoers_setlocale(oldlocale, NULL);
if (!quiet)
sudo_warnx(U_("failed to parse %s file, unknown error"), sudoers_path);
parse_error = true;
- errorfile = sudoers_path;
+ free(errorfile);
+ if ((errorfile = strdup(sudoers_path)) == NULL)
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
ret = !parse_error;