ifcfg-rh: fix unescaping single quotes in WPA passphrases (WPA_PSK) (rh #833616)

When the last character of the PSK was a backslash and the whole PSK was
enclosed in single quotes, the unquoting/unescaping code mistakenly took
trailing \' as an escaped quote and thus changed \ to '.

See also 79757f10f3 (that introduced the code).
This commit is contained in:
Jiří Klimeš 2012-06-22 13:04:18 +02:00
parent c0048e7b40
commit 4938996973
3 changed files with 4 additions and 4 deletions

View file

@ -1,2 +1,2 @@
WPA_PSK=$'They\'re really saying I love you. >>`<<'
WPA_PSK=$'They\'re really saying I love you. >>`<< \'

View file

@ -4927,7 +4927,7 @@ test_read_wifi_wpa_psk_2 (void)
GError *error = NULL;
const char *tmp;
const char *expected_id = "System ipsum (test-wifi-wpa-psk-2)";
const char *expected_psk = "They're really saying I love you. >>`<<";
const char *expected_psk = "They're really saying I love you. >>`<< \\";
connection = connection_from_file (TEST_IFCFG_WIFI_WPA_PSK_2,
NULL,
@ -12858,7 +12858,7 @@ int main (int argc, char **argv)
FALSE,
TRUE,
TRUE,
"blah`oops\"grr'$*@~!%");
"blah`oops\"grr'$*@~!%\\");
test_write_wifi_wpa_psk_adhoc ();
test_write_wifi_wpa_eap_tls ();
test_write_wifi_wpa_eap_ttls_tls ();

View file

@ -189,7 +189,7 @@ utils_single_unquote_string (const char *str)
i = quote + dollar;
while (i < slen - quote) {
if (str[i] == escape_char && str[i+1] == q_char)
if (str[i] == escape_char && str[i+1] == q_char && i+1 < slen-quote)
i++;
new_str[j++] = str[i++];
}