mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-28 04:37:13 +09:00
Support randombytes() with size == 0, but don't force implementations to support it
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user