mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-07 01:35:23 +00:00
Convert the parser to C++
This conversion is nothing more than what is required to get it to compile. Further improvements will come as the code is refactored. Unfortunately due to C++ not supporting designated initializers, the auto generation of af names needed to be reworked, and "netlink" and "unix" domain socket keywords leaked in. Since these where going to be added in separate patches I have not bothered to do the extra work to replace them with a temporary place holder. Signed-off-by: John Johansen <john.johansen@canonical.com> [tyhicks: merged with dbus changes and memory leak fixes] Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com> Acked-by: Steve Beattie <steve@nxnw.org>
This commit is contained in:
committed by
Tyler Hicks
parent
b0a1488820
commit
a34059b1e5
@@ -54,29 +54,29 @@ static inline char *get_var_end(char *var)
|
||||
static struct var_string *split_string(char *string, char *var_begin,
|
||||
char *var_end)
|
||||
{
|
||||
struct var_string *new = calloc(1, sizeof(struct var_string));
|
||||
struct var_string *n = (struct var_string *) calloc(1, sizeof(struct var_string));
|
||||
unsigned int offset = strlen("@{");
|
||||
if (!new) {
|
||||
if (!n) {
|
||||
PERROR("Memory allocation error\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (var_begin != string) {
|
||||
new->prefix = strndup(string, var_begin - string);
|
||||
n->prefix = strndup(string, var_begin - string);
|
||||
}
|
||||
|
||||
new->var = strndup(var_begin + offset, var_end - (var_begin + offset));
|
||||
n->var = strndup(var_begin + offset, var_end - (var_begin + offset));
|
||||
|
||||
if (strlen(var_end + 1) != 0) {
|
||||
new->suffix = strdup(var_end + 1);
|
||||
n->suffix = strdup(var_end + 1);
|
||||
}
|
||||
|
||||
return new;
|
||||
return n;
|
||||
}
|
||||
|
||||
struct var_string *split_out_var(char *string)
|
||||
{
|
||||
struct var_string *new = NULL;
|
||||
struct var_string *n = NULL;
|
||||
char *sptr;
|
||||
BOOL bEscape = 0; /* flag to indicate escape */
|
||||
|
||||
@@ -85,7 +85,7 @@ struct var_string *split_out_var(char *string)
|
||||
|
||||
sptr = string;
|
||||
|
||||
while (!new && *sptr) {
|
||||
while (!n && *sptr) {
|
||||
switch (*sptr) {
|
||||
case '\\':
|
||||
if (bEscape) {
|
||||
@@ -106,7 +106,7 @@ struct var_string *split_out_var(char *string)
|
||||
PERROR("Empty variable name found!\n");
|
||||
exit(1);
|
||||
}
|
||||
new = split_string(string, sptr, eptr);
|
||||
n = split_string(string, sptr, eptr);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -116,7 +116,7 @@ struct var_string *split_out_var(char *string)
|
||||
sptr++;
|
||||
}
|
||||
|
||||
return new;
|
||||
return n;
|
||||
}
|
||||
|
||||
void free_var_string(struct var_string *var)
|
||||
@@ -191,7 +191,7 @@ static int expand_entry_variables(char **name, void *entry,
|
||||
|
||||
int clone_and_chain_cod(void *v)
|
||||
{
|
||||
struct cod_entry *entry = v;
|
||||
struct cod_entry *entry = (struct cod_entry *) v;
|
||||
struct cod_entry *dup = copy_cod_entry(entry);
|
||||
if (!dup)
|
||||
return 0;
|
||||
@@ -203,7 +203,7 @@ int clone_and_chain_cod(void *v)
|
||||
|
||||
int clone_and_chain_mnt(void *v)
|
||||
{
|
||||
struct mnt_entry *entry = v;
|
||||
struct mnt_entry *entry = (struct mnt_entry *) v;
|
||||
|
||||
struct mnt_entry *dup = dup_mnt_entry(entry);
|
||||
if (!dup)
|
||||
@@ -216,7 +216,7 @@ int clone_and_chain_mnt(void *v)
|
||||
|
||||
int clone_and_chain_dbus(void *v)
|
||||
{
|
||||
struct dbus_entry *entry = v;
|
||||
struct dbus_entry *entry = (struct dbus_entry *) v;
|
||||
|
||||
struct dbus_entry *dup = dup_dbus_entry(entry);
|
||||
if (!dup)
|
||||
|
Reference in New Issue
Block a user