mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Fix error case of aa_getprocattr to set buffers to NULL
While aa_getprocattr does return the documented error code on failure the **buf and **mode parameters can point into the buffer that was allocated and then discarded on failure. Set them to null on failure so that even if the error code is ignored they do not point to heap data. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-By: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
2e3b5ff134
commit
648166ecca
1 changed files with 3 additions and 0 deletions
|
@ -278,6 +278,8 @@ int aa_getprocattr(pid_t tid, const char *attr, char **buf, char **mode)
|
|||
|
||||
if (rc == -1) {
|
||||
free(buffer);
|
||||
*buf = NULL;
|
||||
*mode = NULL;
|
||||
size = -1;
|
||||
} else
|
||||
*buf = buffer;
|
||||
|
@ -617,6 +619,7 @@ int aa_getpeercon(int fd, char **con)
|
|||
|
||||
if (rc == -1) {
|
||||
free(buffer);
|
||||
*con = NULL;
|
||||
size = -1;
|
||||
} else
|
||||
*con = buffer;
|
||||
|
|
Loading…
Add table
Reference in a new issue