2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 22:05:27 +00:00

add correct line number and filename tracking for error conditions (LP: #588014)

Bug: https://launchpad.net/bugs/588014
This commit is contained in:
Kees Cook
2010-06-04 18:47:44 -07:00
parent 67bd489ba8
commit 7cfc7e1133
12 changed files with 287 additions and 26 deletions

View File

@@ -89,8 +89,6 @@ int perms_create = 0; /* perms contain create flag */
char *profile_namespace = NULL;
int flag_changehat_version = FLAG_CHANGEHAT_1_5;
extern int current_lineno;
/* per-profile settings */
int force_complain = 0;
char *profilename = NULL;
@@ -228,8 +226,10 @@ void pwarn(char *fmt, ...)
if (conf_quiet || names_only || option == OPTION_REMOVE)
return;
rc = asprintf(&newfmt, _("Warning (%s line %d): %s"),
rc = asprintf(&newfmt, _("Warning from %s (%s%sline %d): %s"),
profilename ? profilename : "stdin",
current_filename ? current_filename : "",
current_filename ? " " : "",
current_lineno,
fmt);
if (!newfmt)
@@ -699,12 +699,13 @@ int process_binary(int option, char *profilename)
return retval;
}
void reset_parser(void)
void reset_parser(char *filename)
{
free_aliases();
free_symtabs();
free_policies();
reset_regex();
reset_include_stack(filename);
}
int process_profile(int option, char *profilename)
@@ -800,7 +801,7 @@ int process_profile(int option, char *profilename)
if (yyin)
yyrestart(yyin);
reset_parser();
reset_parser(profilename);
retval = yyparse();
if (retval != 0)