|
From: <sv...@va...> - 2010-06-07 14:15:18
|
Author: sewardj
Date: 2010-06-07 15:15:08 +0100 (Mon, 07 Jun 2010)
New Revision: 11158
Log:
Remove stdio dependency from arc4random intercepts. (Filipe Cabecinhas).
See #205241 comment 30.
Modified:
branches/MACOSX106/coregrind/vg_preloaded.c
Modified: branches/MACOSX106/coregrind/vg_preloaded.c
===================================================================
--- branches/MACOSX106/coregrind/vg_preloaded.c 2010-06-07 12:36:06 UTC (rev 11157)
+++ branches/MACOSX106/coregrind/vg_preloaded.c 2010-06-07 14:15:08 UTC (rev 11158)
@@ -151,17 +151,18 @@
Darwin arc4random (rdar://6166275)
------------------------------------------------------------------ */
-#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
int VG_REPLACE_FUNCTION_ZU(libSystemZdZaZddylib, arc4random)(void);
int VG_REPLACE_FUNCTION_ZU(libSystemZdZaZddylib, arc4random)(void)
{
- static FILE *rnd = 0;
+ static int rnd = -1;
int result;
- if (!rnd) rnd = fopen("/dev/random", "r");
-
- fread(&result, sizeof(result), 1, rnd);
+ if (rnd < 0) rnd = open("/dev/random", O_RDONLY);
+
+ read(rnd, &result, sizeof(result));
return result;
}
|