2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

libapparmor: fix log parsing memory leaks

This patch fixes some memory leaks in the libapparmor log parsing
functions, specifically around handling records obtained from syslog
and records containing network addresses.

Bug: https://bugs.launchpad.net/bugs/1340927
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
Steve Beattie
2014-07-11 15:59:21 -07:00
parent 16d7e971c3
commit c71af8b926
2 changed files with 13 additions and 7 deletions

View File

@@ -196,15 +196,15 @@ other_audit: TOK_TYPE_OTHER audit_msg TOK_MSG_REST
syslog_type:
syslog_date TOK_ID TOK_SYSLOG_KERNEL audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); free($4); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); free($4); }
| syslog_date TOK_ID TOK_SYSLOG_USER key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
;
/* when audit dispatches a message it doesn't prepend the audit type string */
@@ -229,8 +229,10 @@ audit_id: TOK_AUDIT TOK_OPEN_PAREN TOK_AUDIT_DIGITS TOK_PERIOD TOK_AUDIT_DIGITS
free($7);
} ;
syslog_date: TOK_DATE_MONTH TOK_DIGITS TOK_TIME { /* do nothing? */ }
| TOK_DATE TOK_TIME { /* do nothing */ }
syslog_date: TOK_DATE_MONTH TOK_DIGITS TOK_TIME
{ free($1); free($3); /* do nothing */ }
| TOK_DATE TOK_TIME
{ free($1); free($2); /* do nothing */ }
;
key_list: key

View File

@@ -81,6 +81,10 @@ void free_record(aa_log_record *record)
free(record->net_protocol);
if (record->net_sock_type != NULL)
free(record->net_sock_type);
if (record->net_local_addr != NULL)
free(record->net_local_addr);
if (record->net_foreign_addr != NULL)
free(record->net_foreign_addr);
if (record->dbus_bus != NULL)
free(record->dbus_bus);
if (record->dbus_path != NULL)