Index: lib/libc/gen/auxv.3 =================================================================== --- lib/libc/gen/auxv.3 +++ lib/libc/gen/auxv.3 @@ -68,11 +68,11 @@ .Sh ERRORS .Bl -tag -width Er .It Bq Er EINVAL -An unknown item was requested. -.It Bq Er EINVAL The provided buffer was not the right size for the requested item. .It Bq Er ENOENT The requested item is not available. +.It Bq Er ENOENT +An unknown item was requested. .El .Sh HISTORY The Index: lib/libc/gen/auxv.c =================================================================== --- lib/libc/gen/auxv.c +++ lib/libc/gen/auxv.c @@ -140,27 +140,36 @@ switch (aux) { case AT_CANARY: - if (canary != NULL && buflen >= canary_len) { - memcpy(buf, canary, canary_len); - memset(canary, 0, canary_len); - canary = NULL; - res = 0; + if (buflen >= canary_len) { + if (canary != NULL) { + memcpy(buf, canary, canary_len); + memset(canary, 0, canary_len); + canary = NULL; + res = 0; + } else + res = ENOENT; } else - res = ENOENT; + res = EINVAL; break; case AT_HWCAP: - if (hwcap_present && buflen >= sizeof(u_long)) { - *(u_long *)buf = hwcap; - res = 0; + if (buflen >= sizeof(u_long)) { + if (hwcap_present) { + *(u_long *)buf = hwcap; + res = 0; + } else + res = ENOENT; } else - res = ENOENT; + res = EINVAL; break; case AT_HWCAP2: - if (hwcap2_present && buflen >= sizeof(u_long)) { - *(u_long *)buf = hwcap2; - res = 0; + if (buflen >= sizeof(u_long)) { + if (hwcap2_present) { + *(u_long *)buf = hwcap2; + res = 0; + } else + res = ENOENT; } else - res = ENOENT; + res = EINVAL; break; case AT_NCPUS: if (buflen >= sizeof(int)) { @@ -173,11 +182,14 @@ res = EINVAL; break; case AT_PAGESIZES: - if (pagesizes != NULL && buflen >= pagesizes_len) { - memcpy(buf, pagesizes, pagesizes_len); - res = 0; + if (buflen >= pagesizes_len) { + if (pagesizes != NULL) { + memcpy(buf, pagesizes, pagesizes_len); + res = 0; + } else + res = ENOENT; } else - res = ENOENT; + res = EINVAL; break; case AT_PAGESZ: if (buflen >= sizeof(int)) {