Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04ccd53f authored by John Johansen's avatar John Johansen Committed by James Morris
Browse files

AppArmor: Fix splitting an fqname into separate namespace and profile names



As per Dan Carpenter <error27@gmail.com>
  If we have a ns name without a following profile then in the original
  code it did "*ns_name = &name[1];".  "name" is NULL so "*ns_name" is
  0x1.  That isn't useful and could cause an oops when this function is
  called from aa_remove_profiles().

Beyond this the assignment of the namespace name was wrong in the case
where the profile name was provided as it was being set to &name[1]
after name  = skip_spaces(split + 1);

Move the ns_name assignment before updating name for the split and
also add skip_spaces, making the interface more robust.

Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 3a2dc838
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ char *aa_split_fqname(char *fqname, char **ns_name)
	*ns_name = NULL;
	*ns_name = NULL;
	if (name[0] == ':') {
	if (name[0] == ':') {
		char *split = strchr(&name[1], ':');
		char *split = strchr(&name[1], ':');
		*ns_name = skip_spaces(&name[1]);
		if (split) {
		if (split) {
			/* overwrite ':' with \0 */
			/* overwrite ':' with \0 */
			*split = 0;
			*split = 0;
@@ -47,7 +48,6 @@ char *aa_split_fqname(char *fqname, char **ns_name)
		} else
		} else
			/* a ns name without a following profile is allowed */
			/* a ns name without a following profile is allowed */
			name = NULL;
			name = NULL;
		*ns_name = &name[1];
	}
	}
	if (name && *name == 0)
	if (name && *name == 0)
		name = NULL;
		name = NULL;