Support randombytes() with size == 0, but don't force implementations to support it
This commit is contained in:
parent
b64f19d439
commit
08755e04e1
@ -46,7 +46,9 @@ randombytes_uniform(const uint32_t upper_bound)
|
||||
void
|
||||
randombytes_buf(void * const buf, const size_t size)
|
||||
{
|
||||
implementation->buf(buf, size);
|
||||
if (size > (size_t) 0U) {
|
||||
implementation->buf(buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -85,6 +85,7 @@ safe_read(const int fd, void * const buf_, size_t count)
|
||||
unsigned char *buf = (unsigned char *) buf_;
|
||||
ssize_t readnb;
|
||||
|
||||
assert(count > (size_t) 0U);
|
||||
do {
|
||||
while ((readnb = read(fd, buf, count)) < (ssize_t) 0 &&
|
||||
errno == EINTR);
|
||||
|
@ -45,6 +45,7 @@ safe_read(const int fd, void * const buf_, size_t count)
|
||||
unsigned char *buf = (unsigned char *) buf_;
|
||||
ssize_t readnb;
|
||||
|
||||
assert(count > (size_t) 0U);
|
||||
do {
|
||||
while ((readnb = read(fd, buf, count)) < (ssize_t) 0 &&
|
||||
errno == EINTR);
|
||||
|
Loading…
Reference in New Issue
Block a user