diff options
author | dcashman <dcashman@android.com> | 2016-02-23 12:23:59 -0800 |
---|---|---|
committer | Stephen Smalley <sds@tycho.nsa.gov> | 2016-02-24 09:18:59 -0500 |
commit | f77021d720f12767576c25d751c75cacd7478614 (patch) | |
tree | a8f4d6e3ff5242f91834c1f106ae90b6eaa54829 /libselinux/src/procattr.c | |
parent | 2b69984b0c13203a022d38497c1cc427f279ca78 (diff) | |
download | android_external_selinux-f77021d720f12767576c25d751c75cacd7478614.tar.gz android_external_selinux-f77021d720f12767576c25d751c75cacd7478614.tar.bz2 android_external_selinux-f77021d720f12767576c25d751c75cacd7478614.zip |
libselinux: procattr: return error on invalid pid_t input.
Signed-off-by: Daniel Cashman <dcashman@android.com>
Diffstat (limited to 'libselinux/src/procattr.c')
-rw-r--r-- | libselinux/src/procattr.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c index 527a0a5c..c20f003a 100644 --- a/libselinux/src/procattr.c +++ b/libselinux/src/procattr.c @@ -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; |