mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
Subject: parser - use DUP_STRING more widely and detect strdup errors
This patch moves the DUP_STRING macro to parser.h and modifies it to accept a goto error target, that will be jumped to if the call to strdup(3) fails. It also uses it in additional locations where copying structures occurs, as well as detecting additional cases where a structure duplication might have failed but not been propagated outward. Signed-off-by: Steve Beattie <steve@nxnw.org> Acked-by: Tyler Hicks <tyhicks@canonical.com>
This commit is contained in:
@@ -840,9 +840,9 @@ struct cod_entry *copy_cod_entry(struct cod_entry *orig)
|
||||
if (!entry)
|
||||
return NULL;
|
||||
|
||||
entry->namespace = orig->namespace ? strdup(orig->namespace) : NULL;
|
||||
entry->name = strdup(orig->name);
|
||||
entry->link_name = orig->link_name ? strdup(orig->link_name) : NULL;
|
||||
DUP_STRING(orig, entry, namespace, err);
|
||||
DUP_STRING(orig, entry, name, err);
|
||||
DUP_STRING(orig, entry, link_name, err);
|
||||
entry->mode = orig->mode;
|
||||
entry->audit = orig->audit;
|
||||
entry->deny = orig->deny;
|
||||
@@ -854,6 +854,10 @@ struct cod_entry *copy_cod_entry(struct cod_entry *orig)
|
||||
entry->next = orig->next;
|
||||
|
||||
return entry;
|
||||
|
||||
err:
|
||||
free_cod_entries(entry);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void free_cod_entries(struct cod_entry *list)
|
||||
|
Reference in New Issue
Block a user