Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

apparmor: Replace deprecated strcpy in d_namespace_path

strcpy() is deprecated; replace it with a direct '/' assignment. The
buffer is already NUL-terminated, so there is no need to copy an
additional NUL terminator as strcpy() did.

Update the comment and add the local variable 'is_root' for clarity.

Closes: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: John Johansen <john.johansen@canonical.com>

authored by

Thorsten Blum and committed by
John Johansen
93d4dbdc b31d3f73

+8 -5
+8 -5
security/apparmor/path.c
··· 164 164 } 165 165 166 166 out: 167 - /* 168 - * Append "/" to the pathname. The root directory is a special 169 - * case; it already ends in slash. 167 + /* Append "/" to directory paths, except for root "/" which 168 + * already ends in a slash. 170 169 */ 171 - if (!error && isdir && ((*name)[1] != '\0' || (*name)[0] != '/')) 172 - strcpy(&buf[aa_g_path_max - 2], "/"); 170 + if (!error && isdir) { 171 + bool is_root = (*name)[0] == '/' && (*name)[1] == '\0'; 172 + 173 + if (!is_root) 174 + buf[aa_g_path_max - 2] = '/'; 175 + } 173 176 174 177 return error; 175 178 }