dajobe / flickcurl

Flickr C API library

Home Page:http://librdf.org/flickcurl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parameters do not seem to be resetting

patrickjennings opened this issue · comments

In 1.26 and the latest in this repository, I have found that the parameters used to create each URI are not being reset after subsequent calls to some methods used in flickcurl. Please look at the following Gist as an example:

https://gist.github.com/patrickjennings/0d5657d2463395c4e229

The program fails at flickcurl_oauth_create_access_token because the parameters used in the call to flickcurl_oauth_create_request_token are still present in the URI created for the call. If I do not use the function flickcurl_oauth_create_request_token before flickcurl_oauth_create_access_token, the program works properly.

Is there a way to clear the parameters used to create the URI for each API call or should flickcurl reset the parameter list each time an API call is made?

Looks like it is repeating parameters and has some garbage values too like a timestamp of '%40xy%01'

I've a candidate flaw; the wrong function is called in those methods to reset the parameters.

Candidate fix:

diff --git a/src/oauth.c b/src/oauth.c
index 8ac4e3c..95f09a2 100644
--- a/src/oauth.c
+++ b/src/oauth.c
@@ -709,7 +709,7 @@ flickcurl_oauth_create_request_token(flickcurl* fc, const char* callback)
   int i;
   int count;

-  flickcurl_end_params(fc);
+  flickcurl_init_params(fc, 0);

   /* Require signature */
   flickcurl_set_sign(fc);
@@ -857,7 +857,7 @@ flickcurl_oauth_create_access_token(flickcurl* fc, const char* verifier)
   if(!verifier)
     return 1;

-  flickcurl_end_params(fc);
+  flickcurl_init_params(fc, 0);

   /* Require signature */
   flickcurl_set_sign(fc);

I tested the fix. Everything seems to work afterwards. Thank you for taking the time to create and maintain this library!