summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-0.7.2/wpa_supplicant-fix-deprecated-dbus-function.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-0.7.2/wpa_supplicant-fix-deprecated-dbus-function.patch')
-rw-r--r--meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-0.7.2/wpa_supplicant-fix-deprecated-dbus-function.patch187
1 files changed, 187 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-0.7.2/wpa_supplicant-fix-deprecated-dbus-function.patch b/meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-0.7.2/wpa_supplicant-fix-deprecated-dbus-function.patch
new file mode 100644
index 0000000000..dbd5e4e934
--- /dev/null
+++ b/meta/recipes-connectivity/wpa-supplicant/wpa-supplicant-0.7.2/wpa_supplicant-fix-deprecated-dbus-function.patch
@@ -0,0 +1,187 @@
1--- dbus_dict_helpers.c.array-fix 2006-12-18 12:31:11.000000000 -0500
2+++ dbus_dict_helpers.c 2006-12-20 03:17:08.000000000 -0500
3@@ -629,36 +629,55 @@ dbus_bool_t wpa_dbus_dict_open_read(DBus
4 }
5
6
7+#define BYTE_ARRAY_CHUNK_SIZE 34
8+#define BYTE_ARRAY_ITEM_SIZE (sizeof (char))
9+
10 static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
11- DBusMessageIter *iter, int array_len, int array_type,
12+ DBusMessageIter *iter, int array_type,
13 struct wpa_dbus_dict_entry *entry)
14 {
15- dbus_uint32_t i = 0;
16+ dbus_uint32_t count = 0;
17 dbus_bool_t success = FALSE;
18- char byte;
19+ char * buffer;
20
21- /* Zero-length arrays are valid. */
22- if (array_len == 0) {
23- entry->bytearray_value = NULL;
24- entry->array_type = DBUS_TYPE_BYTE;
25- success = TRUE;
26- goto done;
27- }
28+ entry->bytearray_value = NULL;
29+ entry->array_type = DBUS_TYPE_BYTE;
30
31- entry->bytearray_value = wpa_zalloc(array_len * sizeof(char));
32- if (!entry->bytearray_value) {
33+ buffer = wpa_zalloc(BYTE_ARRAY_ITEM_SIZE * BYTE_ARRAY_CHUNK_SIZE);
34+ if (!buffer) {
35 perror("_wpa_dbus_dict_entry_get_byte_array[dbus]: out of "
36 "memory");
37 goto done;
38 }
39
40- entry->array_type = DBUS_TYPE_BYTE;
41- entry->array_len = array_len;
42+ entry->bytearray_value = buffer;
43+ entry->array_len = 0;
44 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) {
45+ char byte;
46+
47+ if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
48+ buffer = realloc(buffer, BYTE_ARRAY_ITEM_SIZE * (count + BYTE_ARRAY_CHUNK_SIZE));
49+ if (buffer == NULL) {
50+ perror("_wpa_dbus_dict_entry_get_byte_array["
51+ "dbus] out of memory trying to "
52+ "retrieve the string array");
53+ goto done;
54+ }
55+ }
56+ entry->bytearray_value = buffer;
57+
58 dbus_message_iter_get_basic(iter, &byte);
59- entry->bytearray_value[i++] = byte;
60+ entry->bytearray_value[count] = byte;
61+ entry->array_len = ++count;
62 dbus_message_iter_next(iter);
63 }
64+
65+ /* Zero-length arrays are valid. */
66+ if (entry->array_len == 0) {
67+ free(entry->bytearray_value);
68+ entry->strarray_value = NULL;
69+ }
70+
71 success = TRUE;
72
73 done:
74@@ -666,8 +685,11 @@ done:
75 }
76
77
78+#define STR_ARRAY_CHUNK_SIZE 8
79+#define STR_ARRAY_ITEM_SIZE (sizeof (char *))
80+
81 static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
82- DBusMessageIter *iter, int array_len, int array_type,
83+ DBusMessageIter *iter, int array_type,
84 struct wpa_dbus_dict_entry *entry)
85 {
86 dbus_uint32_t count = 0;
87@@ -677,13 +699,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_
88 entry->strarray_value = NULL;
89 entry->array_type = DBUS_TYPE_STRING;
90
91- /* Zero-length arrays are valid. */
92- if (array_len == 0) {
93- success = TRUE;
94- goto done;
95- }
96-
97- buffer = wpa_zalloc(sizeof (char *) * 8);
98+ buffer = wpa_zalloc(STR_ARRAY_ITEM_SIZE * STR_ARRAY_CHUNK_SIZE);
99 if (buffer == NULL) {
100 perror("_wpa_dbus_dict_entry_get_string_array[dbus] out of "
101 "memory trying to retrieve a string array");
102@@ -696,18 +712,14 @@ static dbus_bool_t _wpa_dbus_dict_entry_
103 const char *value;
104 char *str;
105
106- if ((count % 8) == 0 && count != 0) {
107- char **tmp;
108- tmp = realloc(buffer, sizeof(char *) * (count + 8));
109- if (tmp == NULL) {
110+ if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
111+ buffer = realloc(buffer, STR_ARRAY_ITEM_SIZE * (count + STR_ARRAY_CHUNK_SIZE));
112+ if (buffer == NULL) {
113 perror("_wpa_dbus_dict_entry_get_string_array["
114 "dbus] out of memory trying to "
115 "retrieve the string array");
116- free(buffer);
117- buffer = NULL;
118 goto done;
119 }
120- buffer = tmp;
121 }
122 entry->strarray_value = buffer;
123
124@@ -723,6 +735,13 @@ static dbus_bool_t _wpa_dbus_dict_entry_
125 entry->array_len = ++count;
126 dbus_message_iter_next(iter);
127 }
128+
129+ /* Zero-length arrays are valid. */
130+ if (entry->array_len == 0) {
131+ free(entry->strarray_value);
132+ entry->strarray_value = NULL;
133+ }
134+
135 success = TRUE;
136
137 done:
138@@ -734,7 +753,6 @@ static dbus_bool_t _wpa_dbus_dict_entry_
139 DBusMessageIter *iter_dict_val, struct wpa_dbus_dict_entry *entry)
140 {
141 int array_type = dbus_message_iter_get_element_type(iter_dict_val);
142- int array_len;
143 dbus_bool_t success = FALSE;
144 DBusMessageIter iter_array;
145
146@@ -743,20 +761,14 @@ static dbus_bool_t _wpa_dbus_dict_entry_
147
148 dbus_message_iter_recurse(iter_dict_val, &iter_array);
149
150- array_len = dbus_message_iter_get_array_len(&iter_array);
151- if (array_len < 0)
152- return FALSE;
153-
154 switch (array_type) {
155 case DBUS_TYPE_BYTE:
156 success = _wpa_dbus_dict_entry_get_byte_array(&iter_array,
157- array_len,
158 array_type,
159 entry);
160 break;
161 case DBUS_TYPE_STRING:
162 success = _wpa_dbus_dict_entry_get_string_array(&iter_array,
163- array_len,
164 array_type,
165 entry);
166 break;
167@@ -943,9 +955,17 @@ void wpa_dbus_dict_entry_clear(struct wp
168 break;
169 case DBUS_TYPE_ARRAY:
170 switch (entry->array_type) {
171- case DBUS_TYPE_BYTE:
172- free(entry->bytearray_value);
173- break;
174+ case DBUS_TYPE_BYTE: {
175+ free(entry->bytearray_value);
176+ break;
177+ }
178+ case DBUS_TYPE_STRING: {
179+ int i;
180+ for (i = 0; i < entry->array_len; i++)
181+ free (entry->strarray_value[i]);
182+ free (entry->strarray_value);
183+ break;
184+ }
185 }
186 break;
187 }