Add GETENTROPY_MAX.

This commit is contained in:
Jonas 'Sortie' Termansen 2024-06-23 13:48:56 +02:00
parent 240d227be8
commit 8618c1adf5
2 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, 2017 Jonas 'Sortie' Termansen.
* Copyright (c) 2014, 2016, 2017, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -28,4 +28,8 @@
#define IOV_MAX 1024
#endif
#if __USE_SORTIX || 202405L <= __USE_POSIX
#define GETENTROPY_MAX 256
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, 2016 Jonas 'Sortie' Termansen.
* Copyright (c) 2014, 2015, 2016, 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -24,6 +24,7 @@
#include <string.h>
#include <sortix/clock.h>
#include <sortix/limits.h>
#include <sortix/kernel/addralloc.h>
#include <sortix/kernel/copy.h>
@ -162,7 +163,7 @@ namespace Sortix {
int sys_getentropy(void* user_buffer, size_t size)
{
unsigned char buffer[256];
unsigned char buffer[GETENTROPY_MAX];
if ( sizeof(buffer) < size )
return errno = EIO, -1;
arc4random_buf(buffer, size);