summaryrefslogtreecommitdiff
path: root/lib/gnutls_random.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2003-08-09 17:30:37 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2003-08-09 17:30:37 +0000
commitfc3862bdc14cbb39200ab622cef44e90e49616d3 (patch)
tree1ae2a3ccdd19ba8c79128bb2f9d35069fa9d62b9 /lib/gnutls_random.c
parent04a2b6cdd6a3e4f1d51720e5bb1ea40728ba6ed2 (diff)
downloadgnutls-fc3862bdc14cbb39200ab622cef44e90e49616d3.tar.gz
Applied patch from Arne Thomassen <arne@arne-thomassen.de>, which
corrects several things in the library.
Diffstat (limited to 'lib/gnutls_random.c')
-rw-r--r--lib/gnutls_random.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/gnutls_random.c b/lib/gnutls_random.c
index ffabbe7120..b80639ca1e 100644
--- a/lib/gnutls_random.c
+++ b/lib/gnutls_random.c
@@ -43,15 +43,17 @@ int _gnutls_get_random(opaque * res, int bytes, int level)
int fd;
char *device;
- device = "dev/urandom";
+ device = "/dev/urandom";
fd = open(device, O_RDONLY);
- if (device == NULL || fd < 0) {
+ if (fd < 0) {
_gnutls_log( "Could not open random device\n");
return GNUTLS_E_FILE_ERROR;
} else {
- read(fd, res, bytes);
+ ssize_t err = read(fd, res, bytes);
+ /* IMPLEMENTME: handle EINTR etc. nicely! */
close(fd);
+ if ( (err < 0) || (err < bytes) ) return GNUTLS_E_FILE_ERROR;
}
return 0;
#else /* using gcrypt */
@@ -61,4 +63,3 @@ int _gnutls_get_random(opaque * res, int bytes, int level)
#endif
}
-