gcr: Fix invalid warning when sending a secret exchange
authorStef Walter <stefw@gnome.org>
Sat, 30 Jun 2012 11:10:31 +0000 (13:10 +0200)
committerStef Walter <stefw@gnome.org>
Sat, 30 Jun 2012 11:31:50 +0000 (13:31 +0200)
 * We checked the prefix of the sent data, but didn't correctly
   remove whitespace. In addition the check was inverted
 * Exposed by recent changes to glib, which changed the whitespace
   in the format a GKeyFile slightly

gcr/gcr-secret-exchange.c

index cb3941f..f6eb32e 100644 (file)
@@ -292,9 +292,9 @@ gcr_secret_exchange_begin (GcrSecretExchange *self)
        result = g_key_file_to_data (output, NULL, NULL);
        g_return_val_if_fail (result != NULL, NULL);
 
-       g_strchomp (result);
+       g_strchug (result);
 
-       if (g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX))
+       if (!g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX))
                g_warning ("the prepared data does not have the correct protocol prefix");
 
        g_key_file_free (output);
@@ -540,10 +540,10 @@ gcr_secret_exchange_send (GcrSecretExchange *self,
        result = g_key_file_to_data (output, NULL, NULL);
        g_return_val_if_fail (result != NULL, NULL);
 
-       g_strchomp (result);
+       g_strchug (result);
 
-       if (g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX))
-               g_warning ("the prepared data does not have the correct protocol prefix");
+       if (!g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX))
+               g_warning ("the prepared data does not have the correct protocol prefix: %s", result);
 
        g_key_file_free (output);
        return result;