summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordcashman <dcashman@google.com>2016-02-23 15:59:18 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-02-23 15:59:18 +0000
commit7296351737bfe89b1d2f2671132faae8aa94c207 (patch)
treef0f3495e9d963d54c0e81171934900ebb70e785a
parent237de9cfdd3267409b706dfb64b7c0f1c5bc3678 (diff)
parent78899de14b476a759f4839eae4879d47e36a624a (diff)
downloadlibselinux-7296351737bfe89b1d2f2671132faae8aa94c207.tar.gz
Return error on invalid pid_t input to procattr funcs.
am: 78899de14b * commit '78899de14b476a759f4839eae4879d47e36a624a': Return error on invalid pid_t input to procattr funcs.
-rw-r--r--src/procattr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/procattr.c b/src/procattr.c
index 8569f82..e88e224 100644
--- a/src/procattr.c
+++ b/src/procattr.c
@@ -21,9 +21,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;
@@ -33,6 +33,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;