* [musl] [PATCH] limits.h: define GETENTROPY_MAX
@ 2025-03-24 22:22 Haelwenn (lanodan) Monnier
2025-03-25 9:51 ` Nick Wellnhofer
0 siblings, 1 reply; 3+ messages in thread
From: Haelwenn (lanodan) Monnier @ 2025-03-24 22:22 UTC (permalink / raw)
To: musl; +Cc: Haelwenn (lanodan) Monnier
Part of POSIX.1-2024, added at the same time as getentropy() in Issue 1134:
https://www.austingroupbugs.net/view.php?id=1134
---
include/limits.h | 1 +
src/misc/getentropy.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/limits.h b/include/limits.h
index 53a27b9d..c0085080 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -84,6 +84,7 @@
#define LINE_MAX 4096
#define RE_DUP_MAX 255
+#define GETENTROPY_MAX 256
#define NL_ARGMAX 9
#define NL_MSGMAX 32767
#define NL_SETMAX 255
diff --git a/src/misc/getentropy.c b/src/misc/getentropy.c
index 651ea95f..58004891 100644
--- a/src/misc/getentropy.c
+++ b/src/misc/getentropy.c
@@ -3,13 +3,14 @@
#include <sys/random.h>
#include <pthread.h>
#include <errno.h>
+#include <limits.h>
int getentropy(void *buffer, size_t len)
{
int cs, ret = 0;
char *pos = buffer;
- if (len > 256) {
+ if (len > GETENTROPY_MAX) {
errno = EIO;
return -1;
}
--
2.48.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] [PATCH] limits.h: define GETENTROPY_MAX
2025-03-24 22:22 [musl] [PATCH] limits.h: define GETENTROPY_MAX Haelwenn (lanodan) Monnier
@ 2025-03-25 9:51 ` Nick Wellnhofer
2025-03-25 21:05 ` Rich Felker
0 siblings, 1 reply; 3+ messages in thread
From: Nick Wellnhofer @ 2025-03-25 9:51 UTC (permalink / raw)
To: musl; +Cc: Haelwenn (lanodan) Monnier
On Mar 24, 2025, at 23:22, Haelwenn (lanodan) Monnier <contact@hacktivis.me> wrote:
>
> + if (len > GETENTROPY_MAX) {
> errno = EIO;
> return -1;
> }
POSIX requires EINVAL instead of EIO, so maybe this should be fixed as well.
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] [PATCH] limits.h: define GETENTROPY_MAX
2025-03-25 9:51 ` Nick Wellnhofer
@ 2025-03-25 21:05 ` Rich Felker
0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2025-03-25 21:05 UTC (permalink / raw)
To: Nick Wellnhofer; +Cc: musl, Haelwenn (lanodan) Monnier
On Tue, Mar 25, 2025 at 10:51:25AM +0100, Nick Wellnhofer wrote:
> On Mar 24, 2025, at 23:22, Haelwenn (lanodan) Monnier <contact@hacktivis.me> wrote:
> >
> > + if (len > GETENTROPY_MAX) {
> > errno = EIO;
> > return -1;
> > }
>
> POSIX requires EINVAL instead of EIO, so maybe this should be fixed as well.
Yes, but separate change.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-25 21:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-24 22:22 [musl] [PATCH] limits.h: define GETENTROPY_MAX Haelwenn (lanodan) Monnier
2025-03-25 9:51 ` Nick Wellnhofer
2025-03-25 21:05 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).