mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-05 16:55:32 +00:00
libappamor: Fix mode string NUL-termination of aa_getcon() functions
r2125 caused a regression in aa_getpeercon_raw() when a NULL pointer was passed into the mode parameter. Instead of unconditionally NUL-terminating the con string before the mode portion of the security context, it made it to where the NUL byte was only put into place when mode was non-NULL. This resulted in the con string incorrectly containing the label and the mode. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
@@ -194,6 +194,7 @@ int aa_getprocattr_raw(pid_t tid, const char *attr, char *buf, int len,
|
||||
int rc = -1;
|
||||
int fd, ret;
|
||||
char *tmp = NULL;
|
||||
char *mode_str;
|
||||
int size = 0;
|
||||
|
||||
if (!buf || len <= 0) {
|
||||
@@ -246,8 +247,9 @@ int aa_getprocattr_raw(pid_t tid, const char *attr, char *buf, int len,
|
||||
size++;
|
||||
}
|
||||
|
||||
mode_str = parse_confinement_mode(buf, size);
|
||||
if (mode)
|
||||
*mode = parse_confinement_mode(buf, size);
|
||||
*mode = mode_str;
|
||||
}
|
||||
rc = size;
|
||||
|
||||
|
Reference in New Issue
Block a user