cvs: php4 /ext/mcrypt mcrypt.c

From: Date: Tue, 25 Jul 2000 22:17:20 +0000
Subject: cvs: php4 /ext/mcrypt mcrypt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-922@lists.php.net to get a copy of this message
sas Tue Jul 25 15:17:20 2000 EDT Modified files: /php4/ext/mcrypt mcrypt.c Log: Read from /dev/u?random until the buffer is filled. Submitted by: Derick Rethans <d.rethans@jdimedia.nl> Index: php4/ext/mcrypt/mcrypt.c diff -u php4/ext/mcrypt/mcrypt.c:1.34 php4/ext/mcrypt/mcrypt.c:1.35 --- php4/ext/mcrypt/mcrypt.c:1.34 Mon Jul 10 03:09:14 2000 +++ php4/ext/mcrypt/mcrypt.c Tue Jul 25 15:17:20 2000 @@ -205,6 +205,7 @@ if(source == RANDOM || source == URANDOM) { int fd; + size_t read_bytes = 0; fd = open(source == RANDOM ? "/dev/random" : "/dev/urandom", O_RDONLY); @@ -213,7 +214,13 @@ php_error(E_WARNING, "cannot open source device"); RETURN_FALSE; } - n = read(fd, iv, i); + while (read_bytes < i) { + n = read(fd, iv + read_bytes, i - read_bytes); + if (n < 0) + break; + read_bytes += n; + } + n = read_bytes; close(fd); } else { while(i) {

« previous php.cvs (#922) next »