diff options
author | toshii <toshii@pkgsrc.org> | 2004-02-29 03:45:37 +0000 |
---|---|---|
committer | toshii <toshii@pkgsrc.org> | 2004-02-29 03:45:37 +0000 |
commit | 9f735d6c1a7f836f30feb03e40d67671b43c662a (patch) | |
tree | 4bb45e22561c80ee0d14d87d790c9e87673effcb /mail/clamav/patches | |
parent | 0ca266f86fec12e0794fead01d9397d8ef80bbe7 (diff) | |
download | pkgsrc-9f735d6c1a7f836f30feb03e40d67671b43c662a.tar.gz |
Fread(2)ing /dev/urandom is bad due to libc buffering.
Use read(2) instead.
Diffstat (limited to 'mail/clamav/patches')
-rw-r--r-- | mail/clamav/patches/patch-ac | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/mail/clamav/patches/patch-ac b/mail/clamav/patches/patch-ac new file mode 100644 index 00000000000..810ab8a6dfb --- /dev/null +++ b/mail/clamav/patches/patch-ac @@ -0,0 +1,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 |