mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] getentropy: fix UB if len==0
@ 2020-07-16 23:27 Bartosz Brachaczek
  2020-07-24 18:55 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Bartosz Brachaczek @ 2020-07-16 23:27 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 27 bytes --]

Patch attached.

--Bartosz

[-- Attachment #1.2: Type: text/html, Size: 72 bytes --]

[-- Attachment #2: 0001-getentropy-fix-UB-if-len-0.patch --]
[-- Type: application/octet-stream, Size: 641 bytes --]

From a386bcdd2ba75356eb2123f9281ed7d4932951ec Mon Sep 17 00:00:00 2001
From: Bartosz Brachaczek <b.brachaczek@gmail.com>
Date: Fri, 17 Jul 2020 01:16:28 +0200
Subject: [PATCH] getentropy: fix UB if len==0

if len==0, an uninitalized variable would be returned
---
 src/misc/getentropy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/misc/getentropy.c b/src/misc/getentropy.c
index d2f282ce..651ea95f 100644
--- a/src/misc/getentropy.c
+++ b/src/misc/getentropy.c
@@ -6,7 +6,7 @@
 
 int getentropy(void *buffer, size_t len)
 {
-	int cs, ret;
+	int cs, ret = 0;
 	char *pos = buffer;
 
 	if (len > 256) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] getentropy: fix UB if len==0
  2020-07-16 23:27 [musl] [PATCH] getentropy: fix UB if len==0 Bartosz Brachaczek
@ 2020-07-24 18:55 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-07-24 18:55 UTC (permalink / raw)
  To: musl

On Fri, Jul 17, 2020 at 01:27:21AM +0200, Bartosz Brachaczek wrote:
> Patch attached.

Thanks. Indeed nothing in the spec seems to rule this out, so it
should be supported, even though it's arguably useless.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-24 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 23:27 [musl] [PATCH] getentropy: fix UB if len==0 Bartosz Brachaczek
2020-07-24 18:55 ` 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).