ring: add missing fread return code check
authorFelix Fietkau <nbd@nbd.name>
Mon, 20 Nov 2023 22:01:59 +0000 (23:01 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 20 Nov 2023 22:02:03 +0000 (23:02 +0100)
Fixes build issue with glibc

Signed-off-by: Felix Fietkau <nbd@nbd.name>
ring.c

diff --git a/ring.c b/ring.c
index ba75ac56849ad8d3776f7f15e3d1f40cfb559216..8a7e27fc7eb5c6b7d3abbfb545ddd20be878c494 100644 (file)
--- a/ring.c
+++ b/ring.c
@@ -22,7 +22,8 @@ static uint32_t gen_ring_id(void)
        if (!urandom && (urandom = fopen("/dev/urandom", "r")) == NULL)
                return 0;
 
-       fread(&val, sizeof(val), 1, urandom);
+       if (fread(&val, sizeof(val), 1, urandom) != 1)
+               return 0;
 
        return val;
 }