Line 0
Link Here
|
|
|
1 |
--- gtk+-2/gtksecentry.c.orig 2007-11-19 16:20:50.000000000 +0500 |
2 |
+++ gtk+-2/gtksecentry.c 2008-04-26 22:52:13.000000000 +0600 |
3 |
@@ -256,7 +256,7 @@ |
4 |
|
5 |
static GtkWidgetClass *parent_class = NULL; |
6 |
|
7 |
-gboolean g_use_secure_mem = FALSE; |
8 |
+extern gboolean g_use_secure_mem; |
9 |
|
10 |
# define g_sec_new(type, count) \ |
11 |
((type *) g_sec_malloc ((unsigned) sizeof (type) * (count))) |
12 |
@@ -269,85 +269,6 @@ |
13 |
} while(0) |
14 |
|
15 |
|
16 |
-gpointer |
17 |
-g_malloc(gulong size) |
18 |
-{ |
19 |
- gpointer p; |
20 |
- |
21 |
- if (size == 0) |
22 |
- return NULL; |
23 |
- |
24 |
- if (g_use_secure_mem) |
25 |
- p = (gpointer) secmem_malloc(size); |
26 |
- else |
27 |
- p = (gpointer) malloc(size); |
28 |
- if (!p) |
29 |
- g_error("could not allocate %ld bytes", size); |
30 |
- |
31 |
- return p; |
32 |
-} |
33 |
- |
34 |
-gpointer |
35 |
-g_malloc0(gulong size) |
36 |
-{ |
37 |
- gpointer p; |
38 |
- |
39 |
- if (size == 0) |
40 |
- return NULL; |
41 |
- |
42 |
- if (g_use_secure_mem) { |
43 |
- p = (gpointer) secmem_malloc(size); |
44 |
- if (p) |
45 |
- memset(p, 0, size); |
46 |
- } else |
47 |
- p = (gpointer) calloc(size, 1); |
48 |
- if (!p) |
49 |
- g_error("could not allocate %ld bytes", size); |
50 |
- |
51 |
- return p; |
52 |
-} |
53 |
- |
54 |
-gpointer |
55 |
-g_realloc(gpointer mem, gulong size) |
56 |
-{ |
57 |
- gpointer p; |
58 |
- |
59 |
- if (size == 0) { |
60 |
- g_free(mem); |
61 |
- |
62 |
- return NULL; |
63 |
- } |
64 |
- |
65 |
- if (!mem) { |
66 |
- if (g_use_secure_mem) |
67 |
- p = (gpointer) secmem_malloc(size); |
68 |
- else |
69 |
- p = (gpointer) malloc(size); |
70 |
- } else { |
71 |
- if (g_use_secure_mem) { |
72 |
- g_assert(m_is_secure(mem)); |
73 |
- p = (gpointer) secmem_realloc(mem, size); |
74 |
- } else |
75 |
- p = (gpointer) realloc(mem, size); |
76 |
- } |
77 |
- |
78 |
- if (!p) |
79 |
- g_error("could not reallocate %lu bytes", (gulong) size); |
80 |
- |
81 |
- return p; |
82 |
-} |
83 |
- |
84 |
-void |
85 |
-g_free(gpointer mem) |
86 |
-{ |
87 |
- if (mem) { |
88 |
- if (m_is_secure(mem)) |
89 |
- secmem_free(mem); |
90 |
- else |
91 |
- free(mem); |
92 |
- } |
93 |
-} |
94 |
- |
95 |
GType |
96 |
gtk_secure_entry_get_type(void) |
97 |
{ |
98 |
--- gtk+-2/pinentry-gtk-2.c.orig 2007-11-19 16:44:07.000000000 +0500 |
99 |
+++ gtk+-2/pinentry-gtk-2.c 2008-04-26 22:52:13.000000000 +0600 |
100 |
@@ -39,6 +39,7 @@ |
101 |
|
102 |
#include "gtksecentry.h" |
103 |
#include "pinentry.h" |
104 |
+#include "memory.h" |
105 |
|
106 |
#ifdef FALLBACK_CURSES |
107 |
#include "pinentry-curses.h" |
108 |
@@ -469,12 +470,36 @@ |
109 |
|
110 |
pinentry_cmd_handler_t pinentry_cmd_handler = gtk_cmd_handler; |
111 |
|
112 |
+gboolean g_use_secure_mem = FALSE; |
113 |
+ |
114 |
+static gpointer |
115 |
+_malloc(gsize size) { |
116 |
+ return g_use_secure_mem ? secmem_malloc(size) : malloc(size); |
117 |
+} |
118 |
+ |
119 |
+static gpointer |
120 |
+_realloc(gpointer p, gsize size) { |
121 |
+ return m_is_secure(p) ? secmem_realloc(p, size) : realloc(p, size); |
122 |
+} |
123 |
+ |
124 |
+static void |
125 |
+_free(gpointer p) { |
126 |
+ m_is_secure(p) ? secmem_free(p) : free(p); |
127 |
+} |
128 |
|
129 |
int |
130 |
main (int argc, char *argv[]) |
131 |
{ |
132 |
pinentry_init (PGMNAME); |
133 |
- |
134 |
+ |
135 |
+ GMemVTable mem_vtable = { |
136 |
+ _malloc, |
137 |
+ _realloc, |
138 |
+ _free |
139 |
+ }; |
140 |
+ |
141 |
+ g_mem_set_vtable (&mem_vtable); |
142 |
+ |
143 |
#ifdef FALLBACK_CURSES |
144 |
if (pinentry_have_display (argc, argv)) |
145 |
gtk_init (&argc, &argv); |