mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-08 21:57:34 +00:00
libselinux: procattr: return error on invalid pid_t input.
Signed-off-by: Daniel Cashman <dcashman@android.com>
This commit is contained in:
parent
2b69984b0c
commit
f77021d720
@ -70,9 +70,9 @@ static int openattr(pid_t pid, const char *attr, int flags)
|
||||
char *path;
|
||||
pid_t tid;
|
||||
|
||||
if (pid > 0)
|
||||
if (pid > 0) {
|
||||
rc = asprintf(&path, "/proc/%d/attr/%s", pid, attr);
|
||||
else {
|
||||
} else if (pid == 0) {
|
||||
rc = asprintf(&path, "/proc/thread-self/attr/%s", attr);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
@ -82,6 +82,9 @@ static int openattr(pid_t pid, const char *attr, int flags)
|
||||
free(path);
|
||||
tid = gettid();
|
||||
rc = asprintf(&path, "/proc/self/task/%d/attr/%s", tid, attr);
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user