Skip to content

Commit 528fdb0

Browse files
authored
s_mp_rand_platform.c: s_read_urandom: correctly handle split read
s_read_urandom has a while loop to handle read() that returns less than the full buffer (either due to EINTR or because more than the atomic guarantee from urandom was requested). However, the target of the read was always the base pointer p instead of the updated pointer q, so in the end less than the requested randomness is returned. Use q instead of p in the read() call. Signed-off-by: Arnout Vandecappelle <[email protected]>
1 parent eda0bd6 commit 528fdb0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

s_mp_rand_platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static mp_err s_read_urandom(void *p, size_t n)
9595
if (fd == -1) return MP_ERR;
9696

9797
while (n > 0u) {
98-
ssize_t ret = read(fd, p, n);
98+
ssize_t ret = read(fd, q, n);
9999
if (ret < 0) {
100100
if (errno == EINTR) {
101101
continue;

0 commit comments

Comments
 (0)