summaryrefslogtreecommitdiffstats
path: root/9879affbbdec684adb343b331f47f06788681e3b.patch
blob: a6a451ea92fb5490c137a58f9f082b387bafd15b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From 9879affbbdec684adb343b331f47f06788681e3b Mon Sep 17 00:00:00 2001
From: Thomas Klausner <tk@giga.or.at>
Date: Fri, 6 Oct 2017 12:24:22 +0200
Subject: [PATCH] nonrandomopen: override open64() as well.

---
 regress/nonrandomopen.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/regress/nonrandomopen.c b/regress/nonrandomopen.c
index 4f74222..dd90c14 100644
--- a/regress/nonrandomopen.c
+++ b/regress/nonrandomopen.c
@@ -47,7 +47,8 @@
 #endif
 
 static int inited = 0;
-static int (*real_open)(const char *path, int mode, ...) = NULL;
+static int (*real_open)(const char *path, int flags, ...) = NULL;
+static int (*real_open64)(const char *path, int flags, ...) = NULL;
 
 static void
 init(void)
@@ -55,6 +56,10 @@ init(void)
     real_open = dlsym(RTLD_NEXT, "open");
     if (!real_open)
 	abort();
+    real_open64 = dlsym(RTLD_NEXT, "open64");
+    if (!real_open64) {
+	/* does not have to exist */
+    }
     inited = 1;
 }
 
@@ -78,3 +83,28 @@ open(const char *path, int flags, ...)
 	return real_open(path, flags, mode);
     }
 }
+
+int
+open64(const char *path, int flags, ...)
+{
+    va_list ap;
+    mode_t mode;
+
+    if (!inited) {
+	init();
+    }
+
+    if (!real_open64) {
+	abort();
+    }
+
+    va_start(ap, flags);
+    mode = va_arg(ap, mode_t);
+    va_end(ap);
+
+    if (strcmp(path, "/dev/urandom") == 0) {
+	return real_open64("/dev/zero", flags, mode);
+    } else {
+	return real_open64(path, flags, mode);
+    }
+}