[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox-cvs
Subject: [git commit] seedrng: code shrink
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2022-04-30 13:38:44
Message-ID: 20220430133023.88C0784338 () busybox ! osuosl ! org
[Download RAW message or body]
commit: https://git.busybox.net/busybox/commit/?id=2cbfd01c150420199a9cb74f5de72d7279e6cd11
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Struct initializers do this double init:
># util-linux/seedrng.c:88: struct pollfd random_fd = {
movl $0, 132(%esp) #, random_fd
movl $0, 136(%esp) #, random_fd
...
># util-linux/seedrng.c:88: struct pollfd random_fd = {
movl %eax, 140(%esp) # _110, random_fd.fd
movw $1, 144(%esp) #, random_fd.events
and close(random_fd.fd) needs to pull the item from the stack:
pushl 132(%esp) # random_fd.fd
call close #
function old new delta
seedrng_main 1076 1050 -26
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
util-linux/seedrng.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/util-linux/seedrng.c b/util-linux/seedrng.c
index 5559ba77c..023ed8688 100644
--- a/util-linux/seedrng.c
+++ b/util-linux/seedrng.c
@@ -85,14 +85,14 @@ static bool read_new_seed(uint8_t *seed, size_t len)
return true;
}
if (ret < 0 && errno == ENOSYS) {
- struct pollfd random_fd = {
- .fd = xopen("/dev/random", O_RDONLY),
- .events = POLLIN
- };
+ int fd = xopen("/dev/random", O_RDONLY);
+ struct pollfd random_fd;
+ random_fd.fd = fd;
+ random_fd.events = POLLIN;
is_creditable = poll(&random_fd, 1, 0) == 1;
//This is racy. is_creditable can be set to true here, but other process
//can consume "good" random data from /dev/urandom before we do it below.
- close(random_fd.fd);
+ close(fd);
} else {
if (getrandom(seed, len, GRND_INSECURE) == (ssize_t)len)
return false;
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic