Add GETENTROPY_MAX.
This commit is contained in:
parent
240d227be8
commit
8618c1adf5
2 changed files with 8 additions and 3 deletions
|
@ -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
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -28,4 +28,8 @@
|
||||||
#define IOV_MAX 1024
|
#define IOV_MAX 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __USE_SORTIX || 202405L <= __USE_POSIX
|
||||||
|
#define GETENTROPY_MAX 256
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <sortix/clock.h>
|
#include <sortix/clock.h>
|
||||||
|
#include <sortix/limits.h>
|
||||||
|
|
||||||
#include <sortix/kernel/addralloc.h>
|
#include <sortix/kernel/addralloc.h>
|
||||||
#include <sortix/kernel/copy.h>
|
#include <sortix/kernel/copy.h>
|
||||||
|
@ -162,7 +163,7 @@ namespace Sortix {
|
||||||
|
|
||||||
int sys_getentropy(void* user_buffer, size_t size)
|
int sys_getentropy(void* user_buffer, size_t size)
|
||||||
{
|
{
|
||||||
unsigned char buffer[256];
|
unsigned char buffer[GETENTROPY_MAX];
|
||||||
if ( sizeof(buffer) < size )
|
if ( sizeof(buffer) < size )
|
||||||
return errno = EIO, -1;
|
return errno = EIO, -1;
|
||||||
arc4random_buf(buffer, size);
|
arc4random_buf(buffer, size);
|
||||||
|
|
Loading…
Reference in a new issue