1 |
tetromino |
1.1 |
From 03d80950e960031af977c3037b57d41e36701fb2 Mon Sep 17 00:00:00 2001 |
2 |
|
|
From: Alexandre Rostovtsev <tetromino@gentoo.org> |
3 |
|
|
Date: Sat, 18 Feb 2012 20:03:33 -0500 |
4 |
|
|
Subject: [PATCH] ifnet: do not truncate WPA passwords at '#' character |
5 |
|
|
|
6 |
|
|
We need to do the same thing as wpa_supplicant's own config file parser |
7 |
|
|
and ignore '#' characters that occur between the first and last '"' |
8 |
|
|
characters in a config file line. |
9 |
|
|
|
10 |
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=670381 |
11 |
|
|
--- |
12 |
|
|
src/settings/plugins/ifnet/wpa_parser.c | 13 +++++++++---- |
13 |
|
|
1 files changed, 9 insertions(+), 4 deletions(-) |
14 |
|
|
|
15 |
|
|
diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c |
16 |
|
|
index da2bc3b..f7a5b32 100644 |
17 |
|
|
--- a/src/settings/plugins/ifnet/wpa_parser.c |
18 |
|
|
+++ b/src/settings/plugins/ifnet/wpa_parser.c |
19 |
|
|
@@ -279,16 +279,21 @@ wpa_parser_init (const char *wpa_supplicant_conf) |
20 |
|
|
} else { |
21 |
|
|
GHashTable *network = |
22 |
|
|
g_hash_table_new (g_str_hash, g_str_equal); |
23 |
|
|
- gchar *tmp; |
24 |
|
|
|
25 |
|
|
do { |
26 |
|
|
+ gchar *quote_start, *quote_end = NULL, *comment; |
27 |
|
|
+ |
28 |
|
|
if (line[0] == '#' || line[0] == '\0') { |
29 |
|
|
g_free (line); |
30 |
|
|
continue; |
31 |
|
|
} |
32 |
|
|
- /* ignore inline comments */ |
33 |
|
|
- if ((tmp = strchr (line, '#')) != NULL) |
34 |
|
|
- *tmp = '\0'; |
35 |
|
|
+ /* ignore inline comments unless inside |
36 |
|
|
+ a double-quoted string */ |
37 |
|
|
+ if ((quote_start = strchr (line, '"')) != NULL) |
38 |
|
|
+ quote_end = strrchr (quote_start + 1, '"'); |
39 |
|
|
+ if ((comment = strchr ((quote_end != NULL) ? |
40 |
|
|
+ quote_end : line, '#')) != NULL) |
41 |
|
|
+ *comment = '\0'; |
42 |
|
|
if (strstr (line, "}") != NULL) |
43 |
|
|
complete = TRUE; |
44 |
|
|
add_key_value (network, line); |
45 |
|
|
-- |
46 |
|
|
1.7.8.4 |
47 |
|
|
|