summaryrefslogtreecommitdiff
path: root/mail/clamav/patches/patch-ac
blob: 810ab8a6dfba61384c4f8ceea468dca593228a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$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