coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] randread: unitialized memory fix


From: Mikhail Barashkov
Subject: [PATCH] randread: unitialized memory fix
Date: Tue, 21 Sep 2021 17:40:52 +0300

Randread was allocating memory, but not setting it to 0, resulting, in particular, to a crash in shuf program in E2K CPU protected mode (later on s->bug is used by shuf in ISAAC_MIX as the seed parameter).

This patch makes sure the memory buffer is zeroed out correctly.

diff --git a/gl/lib/randread.c b/gl/lib/randread.c
index 7124e3df0..8e6b1c5b8 100644
--- a/gl/lib/randread.c
+++ b/gl/lib/randread.c
@@ -132,6 +132,7 @@ static struct randread_source *
 simple_new (FILE *source, void const *handler_arg)
 {
   struct randread_source *s = xmalloc (sizeof *s);
+  memset(s, 0, sizeof *s);
   s->source = source;
   s->handler = randread_error;
   s->handler_arg = handler_arg;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]