-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision-2987.patch
89 lines (84 loc) · 2.03 KB
/
revision-2987.patch
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Index: lib/coroipcc.c
===================================================================
--- lib/coroipcc.c (revision 2986)
+++ lib/coroipcc.c (revision 2987)
@@ -288,10 +288,11 @@
void *addr_orig;
void *addr;
int32_t res;
- char buffer[128];
int32_t i;
int32_t written;
-
+ char *buffer;
+ long page_size;
+
snprintf (path, PATH_MAX, "/dev/shm/%s", file);
fd = mkstemp (path);
@@ -307,17 +308,25 @@
if (res == -1) {
goto error_close_unlink;
}
- memset (buffer, 0, sizeof (buffer));
- for (i = 0; i < (bytes / 64); i++) {
+
+ page_size = sysconf(_SC_PAGESIZE);
+ buffer = malloc (page_size);
+ if (buffer == NULL) {
+ goto error_close_unlink;
+ }
+ memset (buffer, 0, page_size);
+ for (i = 0; i < (bytes / page_size); i++) {
retry_write:
- written = write (fd, buffer, 64);
+ written = write (fd, buffer, page_size);
if (written == -1 && errno == EINTR) {
goto retry_write;
}
- if (written != 64) {
+ if (written != page_size) {
+ free (buffer);
goto error_close_unlink;
}
}
+ free (buffer);
addr_orig = mmap (NULL, bytes << 1, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
@@ -386,9 +395,10 @@
void *addr_orig;
void *addr;
int32_t res;
- char buffer[128];
+ char *buffer;
int32_t i;
int32_t written;
+ long page_size;
snprintf (path, PATH_MAX, "/dev/shm/%s", file);
@@ -405,17 +415,24 @@
if (res == -1) {
goto error_close_unlink;
}
- memset (buffer, 0, sizeof (buffer));
- for (i = 0; i < (bytes / 64); i++) {
+ page_size = sysconf(_SC_PAGESIZE);
+ buffer = malloc (page_size);
+ if (buffer == NULL) {
+ goto error_close_unlink;
+ }
+ memset (buffer, 0, page_size);
+ for (i = 0; i < (bytes / page_size); i++) {
retry_write:
- written = write (fd, buffer, 64);
+ written = write (fd, buffer, page_size);
if (written == -1 && errno == EINTR) {
goto retry_write;
}
- if (written != 64) {
+ if (written != page_size) {
+ free (buffer);
goto error_close_unlink;
}
}
+ free (buffer);
addr_orig = mmap (NULL, bytes, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);