[PATCH] "psk" field, in set_network_properties(), was always getting quoted even when containing a raw key (64 characters length representing the hexadecimal value of the raw key).

Tomasz Bursztyka tomasz.bursztyka
Tue Feb 1 23:41:52 PST 2011


---
 wpa_supplicant/dbus/dbus_new_handlers.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 08cdd72..ef230b3 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -195,7 +195,9 @@ static const char *dont_quote[] = {
 	"bssid", NULL
 };
 
-static dbus_bool_t should_quote_opt(const char *key)
+static dbus_bool_t should_quote_opt(const char *key,
+				    size_t value_length,
+				    char *value)
 {
 	int i = 0;
 	while (dont_quote[i] != NULL) {
@@ -203,6 +205,18 @@ static dbus_bool_t should_quote_opt(const char *key)
 			return FALSE;
 		i++;
 	}
+
+	/*
+	 * Do not quote psk value which is a raw key.
+	 */
+	if ((os_strcmp(key, "psk") == 0) && (value_length == PMK_LEN*2)) {
+		u8 tmp_buf[PMK_LEN];
+
+		if (hexstr2bin(value, tmp_buf, PMK_LEN) == 0)
+			return FALSE;
+	}
+
+
 	return TRUE;
 }
 
@@ -273,9 +287,11 @@ static DBusMessage * set_network_properties(DBusMessage *message,
 			if (ret <= 0)
 				goto error;
 		} else if (entry.type == DBUS_TYPE_STRING) {
-			if (should_quote_opt(entry.key)) {
-				size = os_strlen(entry.str_value);
-				if (size <= 0)
+			size = os_strlen(entry.str_value);
+
+			if (should_quote_opt(entry.key, size,
+					     entry.str_value)) {
+				if (size < 0)
 					goto error;
 
 				size += 3;
-- 
1.7.3.4




More information about the Hostap mailing list