diff options
author | Bryan Ischo <bryan@ischo.com> | 2008-12-11 21:48:20 +0000 |
---|---|---|
committer | Bryan Ischo <bryan@ischo.com> | 2008-12-11 21:48:20 +0000 |
commit | 50f6602002c075adc25c1168c4484a3ecd226ced (patch) | |
tree | 3f415ee27fab08b80bef618534f59a90c9dc65fb /src | |
parent | abf868a2e8e9526d25a0bf5283ad4900113ff87d (diff) | |
download | ceph-libs3-50f6602002c075adc25c1168c4484a3ecd226ced.tar.gz |
* Fixed a bug with query parameters using double-? in URI, breaking list
functionality (and possibly other functionality)
* Fixed a memory leak in the list_bucket operation, which was not destroying
the simplexml structure when finished with it
* Fixed a bug discovered and fixed by Erez Strauss, caused by
compiler-dependent ordering of a = b = c statments (I don't understand how
this is compiler-dependent, I thought it was well-defined, but oh well), the
symptoms of which were double calls to the request complete callback when
using request contexts
* Improved some comments
Diffstat (limited to 'src')
-rw-r--r-- | src/acl.c | 4 | ||||
-rw-r--r-- | src/bucket.c | 20 | ||||
-rw-r--r-- | src/request.c | 14 | ||||
-rw-r--r-- | src/s3.c | 4 | ||||
-rw-r--r-- | src/service_access_logging.c | 4 |
5 files changed, 26 insertions, 20 deletions
@@ -129,7 +129,7 @@ void S3_get_acl(const S3BucketContext *bucketContext, const char *key, bucketContext->secretAccessKey }, // secretAccessKey key, // key 0, // queryParams - "?acl", // subResource + "acl", // subResource 0, // copySourceBucketName 0, // copySourceKey 0, // getConditions @@ -329,7 +329,7 @@ void S3_set_acl(const S3BucketContext *bucketContext, const char *key, bucketContext->secretAccessKey }, // secretAccessKey key, // key 0, // queryParams - "?acl", // subResource + "acl", // subResource 0, // copySourceBucketName 0, // copySourceKey 0, // getConditions diff --git a/src/bucket.c b/src/bucket.c index 4f56cb9..9dcc48c 100644 --- a/src/bucket.c +++ b/src/bucket.c @@ -138,7 +138,7 @@ void S3_test_bucket(S3Protocol protocol, S3UriStyle uriStyle, secretAccessKey }, // secretAccessKey 0, // key 0, // queryParams - "?location", // subResource + "location", // subResource 0, // copySourceBucketName 0, // copySourceKey 0, // getConditions @@ -612,6 +612,8 @@ static void listBucketCompleteCallback(S3Status requestStatus, (*(lbData->responseCompleteCallback)) (requestStatus, s3ErrorDetails, lbData->callbackData); + simplexml_deinitialize(&(lbData->simpleXml)); + free(lbData); } @@ -628,11 +630,13 @@ void S3_list_bucket(const S3BucketContext *bucketContext, const char *prefix, #define safe_append(name, value) \ do { \ int fit; \ - string_buffer_append(queryParams, &sep, 1, fit); \ - if (!fit) { \ - (*(handler->responseHandler.completeCallback)) \ - (S3StatusQueryParamsTooLong, 0, callbackData); \ - return; \ + if (amp) { \ + string_buffer_append(queryParams, "&", 1, fit); \ + if (!fit) { \ + (*(handler->responseHandler.completeCallback)) \ + (S3StatusQueryParamsTooLong, 0, callbackData); \ + return; \ + } \ } \ string_buffer_append(queryParams, name "=", \ sizeof(name "=") - 1, fit); \ @@ -641,7 +645,7 @@ void S3_list_bucket(const S3BucketContext *bucketContext, const char *prefix, (S3StatusQueryParamsTooLong, 0, callbackData); \ return; \ } \ - sep = '&'; \ + amp = 1; \ char encoded[3 * 1024]; \ if (!urlEncode(encoded, value, 1024)) { \ (*(handler->responseHandler.completeCallback)) \ @@ -658,7 +662,7 @@ void S3_list_bucket(const S3BucketContext *bucketContext, const char *prefix, } while (0) - char sep = '?'; + int amp = 0; if (prefix) { safe_append("prefix", prefix); } diff --git a/src/request.c b/src/request.c index 9fcd39f..05bf8fb 100644 --- a/src/request.c +++ b/src/request.c @@ -657,6 +657,7 @@ static void canonicalize_resource(const char *bucketName, } if (subResource && subResource[0]) { + append("?"); append(subResource); } } @@ -772,11 +773,11 @@ static S3Status compose_uri(char *buffer, int bufferSize, uri_append("%s", urlEncodedKey); if (subResource && subResource[0]) { - uri_append("%s", subResource); + uri_append("?%s", subResource); } if (queryParams) { - uri_append("%c%s", (subResource && subResource[0]) ? '&' : '?', + uri_append("%s%s", (subResource && subResource[0]) ? "&" : "?", queryParams); } @@ -976,7 +977,8 @@ static S3Status request_get(const RequestParams *params, } // Initialize the request - request->prev = request->next = 0; + request->prev = 0; + request->next = 0; // Request status is initialized to no error, will be updated whenever // an error occurs @@ -1163,8 +1165,8 @@ void request_perform(const RequestParams *params, S3RequestContext *context) if (context->requests) { request->prev = context->requests->prev; request->next = context->requests; - context->requests->prev->next = - context->requests->prev = request; + context->requests->prev->next = request; + context->requests->prev = request; } else { context->requests = request->next = request->prev = request; @@ -1343,7 +1345,7 @@ S3Status S3_generate_authenticated_query_string signbuf_append("%s\n", "GET"); // HTTP-Verb signbuf_append("%s\n", ""); // Content-MD5 signbuf_append("%s\n", ""); // Content-Type - signbuf_append("%llu\n", (uint64_t) expires); + signbuf_append("%llu\n", (unsigned long long) expires); signbuf_append("%s", canonicalizedResource); // Generate an HMAC-SHA-1 of the signbuf @@ -288,8 +288,8 @@ static void usageExit(FILE *out) " gqs : Generates an authenticated query string\n" " <bucket>[/<key>] : Bucket or bucket/key to generate query string for\n" " [expires] : Expiration date for query string\n" -" [resource] : Sub-resource of key for query string, including\n" -" leading '?', for example, \"?torrent\"\n" +" [resource] : Sub-resource of key for query string, without a\n" +" leading '?', for example, \"torrent\"\n" "\n" " Canned ACLs:\n" "\n" diff --git a/src/service_access_logging.c b/src/service_access_logging.c index 417809a..cbed2c1 100644 --- a/src/service_access_logging.c +++ b/src/service_access_logging.c @@ -332,7 +332,7 @@ void S3_get_server_access_logging(const S3BucketContext *bucketContext, bucketContext->secretAccessKey }, // secretAccessKey 0, // key 0, // queryParams - "?logging", // subResource + "logging", // subResource 0, // copySourceBucketName 0, // copySourceKey 0, // getConditions @@ -536,7 +536,7 @@ void S3_set_server_access_logging(const S3BucketContext *bucketContext, bucketContext->secretAccessKey }, // secretAccessKey 0, // key 0, // queryParams - "?logging", // subResource + "logging", // subResource 0, // copySourceBucketName 0, // copySourceKey 0, // getConditions |