From 4a9daa7faf47301915a60e2bef5da3d30a13827f Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Tue, 2 Sep 2014 16:23:32 +0200 Subject: oauth: Make sure RestProxyCall::url is set before using it The oauth "prepare" step needs RestProxyCall::url to be set, but since commit c66b6d this is only set after the "prepare" and "serialize_headers" methods have been called. As it's better if OAuthProxyCall do not directly access RestProxyCall private data, this commit adds a getter to RestProxyCall which will be used to make sure RestProxyCall::url is set when OAuthProxyCall::prepare needs it. https://bugzilla.gnome.org/show_bug.cgi?id=708359 (cherry picked from commit 55f8e9626a50d81fb893508698205057668bf792) --- rest/oauth-proxy-call.c | 6 ++++-- rest/rest-proxy-call-private.h | 2 ++ rest/rest-proxy-call.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/rest/oauth-proxy-call.c b/rest/oauth-proxy-call.c index d8cff95..42b63a0 100644 --- a/rest/oauth-proxy-call.c +++ b/rest/oauth-proxy-call.c @@ -119,12 +119,14 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params) { OAuthProxyPrivate *priv; RestProxyCallPrivate *callpriv; + const char *url_str; char *key, *signature, *ep, *eep; GString *text; GHashTable *all_params; priv = PROXY_GET_PRIVATE (proxy); callpriv = call->priv; + url_str = rest_proxy_call_get_url (call); text = g_string_new (NULL); g_string_append (text, rest_proxy_call_get_method (REST_PROXY_CALL (call))); @@ -132,7 +134,7 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params) if (priv->oauth_echo) { g_string_append_uri_escaped (text, priv->service_url, NULL, FALSE); } else if (priv->signature_host != NULL) { - SoupURI *url = soup_uri_new (callpriv->url); + SoupURI *url = soup_uri_new (url_str); gchar *signing_url; soup_uri_set_host (url, priv->signature_host); @@ -143,7 +145,7 @@ sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params) soup_uri_free (url); g_free (signing_url); } else { - g_string_append_uri_escaped (text, callpriv->url, NULL, FALSE); + g_string_append_uri_escaped (text, url_str, NULL, FALSE); } g_string_append_c (text, '&'); diff --git a/rest/rest-proxy-call-private.h b/rest/rest-proxy-call-private.h index ec7a4be..2647bb3 100644 --- a/rest/rest-proxy-call-private.h +++ b/rest/rest-proxy-call-private.h @@ -52,6 +52,8 @@ struct _RestProxyCallPrivate { RestProxyCallAsyncClosure *cur_call_closure; }; +const char *rest_proxy_call_get_url (RestProxyCall *call); + G_END_DECLS #endif /* _REST_PROXY_CALL_PRIVATE */ diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c index 9c3c9f3..9bd2f7b 100644 --- a/rest/rest-proxy-call.c +++ b/rest/rest-proxy-call.c @@ -1592,3 +1592,14 @@ rest_proxy_call_serialize_params (RestProxyCall *call, return FALSE; } + +G_GNUC_INTERNAL const char * +rest_proxy_call_get_url (RestProxyCall *call) +{ + /* Ensure priv::url is current before returning it. This method is used + * by OAuthProxyCall::_prepare which expects set_url() to have been called, + * but this has been changed/broken by c66b6df + */ + set_url(call); + return call->priv->url; +} -- cgit v1.2.3