mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01: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:
parent
05029cb9b7
commit
54382a9bf5
1 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue