Commit 46401cc9 authored by Thorsten Blum's avatar Thorsten Blum Committed by John Johansen
Browse files

apparmor: Replace memcpy + NUL termination with kmemdup_nul in do_setattr



Use kmemdup_nul() to copy 'value' instead of using memcpy() followed by
a manual NUL termination.  No functional changes.

Reviewed-by: default avatarSerge Hallyn <serge@hallyn.com>
Signed-off-by: default avatarThorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 8813837a
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -856,12 +856,9 @@ static int do_setattr(u64 attr, void *value, size_t size)

	/* AppArmor requires that the buffer must be null terminated atm */
	if (args[size - 1] != '\0') {
		/* null terminate */
		largs = args = kmalloc(size + 1, GFP_KERNEL);
		largs = args = kmemdup_nul(value, size, GFP_KERNEL);
		if (!args)
			return -ENOMEM;
		memcpy(args, value, size);
		args[size] = '\0';
	}

	error = -EINVAL;