35 lines
730 B
Text
35 lines
730 B
Text
$NetBSD: patch-ac,v 1.3 2004/02/29 03:45:37 toshii Exp $
|
|
|
|
--- libclamav/others.c.orig Wed Feb 11 08:03:01 2004
|
|
+++ libclamav/others.c
|
|
@@ -261,13 +261,13 @@
|
|
|
|
unsigned int cl_rndnum(unsigned int max)
|
|
{
|
|
- FILE *fd;
|
|
+ int fd;
|
|
unsigned int generated;
|
|
char *byte;
|
|
int size;
|
|
|
|
|
|
- if((fd = fopen("/dev/urandom", "rb")) == NULL) {
|
|
+ if((fd = open("/dev/urandom", O_RDONLY)) < 0) {
|
|
cli_errmsg("!Can't open /dev/urandom.\n");
|
|
return -1;
|
|
}
|
|
@@ -276,12 +276,12 @@
|
|
size = sizeof(generated);
|
|
do {
|
|
int bread;
|
|
- bread = fread(byte, 1, size, fd);
|
|
+ bread = read(fd, byte, size);
|
|
size -= bread;
|
|
byte += bread;
|
|
} while(size > 0);
|
|
|
|
- fclose(fd);
|
|
+ close(fd);
|
|
return generated % max;
|
|
}
|
|
#endif
|