mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 17:12:50 -04:00
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: Serge Hallyn <serge@hallyn.com> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
committed by
John Johansen
parent
8813837aa7
commit
46401cc99c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user