2
0
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:
Steve Beattie
2013-09-06 13:39:41 -07:00
parent ebabb30abd
commit dd5145131e
4 changed files with 36 additions and 16 deletions

View File

@@ -261,6 +261,13 @@ extern int preprocess_only;
___tmp->next = (LISTB); \
} while (0)
#define DUP_STRING(orig, new, field, fail_target) \
do { \
(new)->field = ((orig)->field) ? strdup((orig)->field) : NULL; \
if (((orig)->field) && !((new)->field)) \
goto fail_target; \
} while (0)
/* from parser_common.c */
extern int regex_type;
extern int perms_create;