mirror of
https://github.com/opnsense/src.git
synced 2026-02-18 18:20:26 -05:00
libc: Fix getentropy POSIX 2024 conformance issues
GETENTROPY_MAX should be defined in limits.h. EINVAL is the return value for buflen > GETENTROPY_MAX. PR: 282783 Reviewed by: markj, asomers, jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47689
This commit is contained in:
parent
1873177473
commit
6789b9f630
3 changed files with 11 additions and 12 deletions
|
|
@ -139,6 +139,10 @@
|
|||
|
||||
#define MB_LEN_MAX 6 /* 31-bit UTF-8 */
|
||||
|
||||
#if __POSIX_VISIBLE >= 202405
|
||||
#define GETENTROPY_MAX 256
|
||||
#endif
|
||||
|
||||
#include <sys/limits.h>
|
||||
|
||||
#if __POSIX_VISIBLE
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd November 20, 2024
|
||||
.Dd January 17, 2025
|
||||
.Dt GETENTROPY 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -60,8 +60,8 @@ The
|
|||
.Fa buf
|
||||
parameter points to an
|
||||
invalid address.
|
||||
.It Bq Er EIO
|
||||
Too many bytes requested, or some other fatal error occurred.
|
||||
.It Bq Er EINVAL
|
||||
Too many bytes requested.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr getrandom 2 ,
|
||||
|
|
@ -69,7 +69,7 @@ Too many bytes requested, or some other fatal error occurred.
|
|||
.Xr random 4
|
||||
.Sh STANDARDS
|
||||
.Fn getentropy
|
||||
nearly conforms to
|
||||
conforms to
|
||||
.St -p1003.1-2024 .
|
||||
.Sh HISTORY
|
||||
The
|
||||
|
|
@ -80,9 +80,3 @@ The
|
|||
.Fx
|
||||
libc compatibility shim first appeared in
|
||||
.Fx 12.0 .
|
||||
.Sh BUGS
|
||||
.In limits.h
|
||||
does not define
|
||||
.Dv GETENTROPY_MAX .
|
||||
Some error values do not match
|
||||
.St -p1003.1-2024 .
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <sys/sysctl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -110,8 +111,8 @@ getentropy(void *buf, size_t buflen)
|
|||
ssize_t rd;
|
||||
bool have_getrandom;
|
||||
|
||||
if (buflen > 256) {
|
||||
errno = EIO;
|
||||
if (buflen > GETENTROPY_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue