aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-10-01 19:56:38 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-10-01 19:56:38 +0000
commit320ef1bef081b626c2e230740d85e72313fbefca (patch)
tree5235659e2c80cc8ab79f31dfb1bd267fc00db112 /lib
parent2398cd110371c495ae71d9a6ece6ed761ccd38a5 (diff)
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/auxv.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/libc/gen/auxv.c b/lib/libc/gen/auxv.c
index 98f2cf4d0ca20..1dbb8ff3c317d 100644
--- a/lib/libc/gen/auxv.c
+++ b/lib/libc/gen/auxv.c
@@ -67,8 +67,7 @@ __init_elf_aux_vector(void)
}
static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
-static int pagesize, osreldate, ncpus, bsdflags;
-static size_t canary_len, pagesizes_len;
+static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags;
static int hwcap_present, hwcap2_present;
static char *canary, *pagesizes, *execpath;
static void *ps_strings, *timekeep;
@@ -246,7 +245,6 @@ int
_elf_aux_info(int aux, void *buf, int buflen)
{
int res;
- size_t buflen_;
__init_elf_aux_vector();
if (__elf_aux_vector == NULL)
@@ -255,12 +253,11 @@ _elf_aux_info(int aux, void *buf, int buflen)
if (buflen < 0)
return (EINVAL);
- buflen_ = (size_t)buflen;
switch (aux) {
case AT_CANARY:
- if (canary != NULL && canary_len >= buflen_) {
- memcpy(buf, canary, buflen_);
+ if (canary != NULL && canary_len >= buflen) {
+ memcpy(buf, canary, buflen);
memset(canary, 0, canary_len);
canary = NULL;
res = 0;
@@ -273,35 +270,36 @@ _elf_aux_info(int aux, void *buf, int buflen)
else if (buf == NULL)
res = EINVAL;
else {
- if (strlcpy(buf, execpath, buflen_) >= buflen_)
+ if (strlcpy(buf, execpath, buflen) >=
+ (unsigned int)buflen)
res = EINVAL;
else
res = 0;
}
break;
case AT_HWCAP:
- if (hwcap_present && buflen_ == sizeof(u_long)) {
+ if (hwcap_present && buflen == sizeof(u_long)) {
*(u_long *)buf = hwcap;
res = 0;
} else
res = ENOENT;
break;
case AT_HWCAP2:
- if (hwcap2_present && buflen_ == sizeof(u_long)) {
+ if (hwcap2_present && buflen == sizeof(u_long)) {
*(u_long *)buf = hwcap2;
res = 0;
} else
res = ENOENT;
break;
case AT_PAGESIZES:
- if (pagesizes != NULL && pagesizes_len >= buflen_) {
- memcpy(buf, pagesizes, buflen_);
+ if (pagesizes != NULL && pagesizes_len >= buflen) {
+ memcpy(buf, pagesizes, buflen);
res = 0;
} else
res = ENOENT;
break;
case AT_PAGESZ:
- if (buflen_ == sizeof(int)) {
+ if (buflen == sizeof(int)) {
if (pagesize != 0) {
*(int *)buf = pagesize;
res = 0;
@@ -311,7 +309,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_OSRELDATE:
- if (buflen_ == sizeof(int)) {
+ if (buflen == sizeof(int)) {
if (osreldate != 0) {
*(int *)buf = osreldate;
res = 0;
@@ -321,7 +319,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_NCPUS:
- if (buflen_ == sizeof(int)) {
+ if (buflen == sizeof(int)) {
if (ncpus != 0) {
*(int *)buf = ncpus;
res = 0;
@@ -331,7 +329,7 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_TIMEKEEP:
- if (buflen_ == sizeof(void *)) {
+ if (buflen == sizeof(void *)) {
if (timekeep != NULL) {
*(void **)buf = timekeep;
res = 0;
@@ -341,14 +339,14 @@ _elf_aux_info(int aux, void *buf, int buflen)
res = EINVAL;
break;
case AT_BSDFLAGS:
- if (buflen_ == sizeof(int)) {
+ if (buflen == sizeof(int)) {
*(int *)buf = bsdflags;
res = 0;
} else
res = EINVAL;
break;
case AT_PS_STRINGS:
- if (buflen_ == sizeof(void *)) {
+ if (buflen == sizeof(void *)) {
if (ps_strings != NULL) {
*(void **)buf = ps_strings;
res = 0;