|
|
@@ -664,9 +664,7 @@ static int headerle(const char *s1, const char *s2, char delim)
|
|
|
}
|
|
|
s1++, s2++;
|
|
|
}
|
|
|
-#ifndef WINSCP
|
|
|
return 0;
|
|
|
-#endif
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -830,7 +828,7 @@ static void sort_query_string(const char *queryString, char *result,
|
|
|
tmp++;
|
|
|
}
|
|
|
|
|
|
- const char** params = new const char*[numParams]; // WINSCP (heap allocation)
|
|
|
+ const char* params[numParams];
|
|
|
|
|
|
// Where did strdup go?!??
|
|
|
int queryStringLen = strlen(queryString);
|
|
|
@@ -868,7 +866,6 @@ static void sort_query_string(const char *queryString, char *result,
|
|
|
}
|
|
|
#undef append
|
|
|
|
|
|
- delete[] params; // WINSCP (heap allocation)
|
|
|
free(buf);
|
|
|
}
|
|
|
|
|
|
@@ -885,12 +882,10 @@ static void canonicalize_query_string(const char *queryParams,
|
|
|
#define append(str) len += snprintf(&(buffer[len]), buffer_size - len, "%s", str)
|
|
|
|
|
|
if (queryParams && queryParams[0]) {
|
|
|
- int sortedLen = strlen(queryParams) * 2;
|
|
|
- char * sorted = new char[sortedLen]; // WINSCP (heap allocation)
|
|
|
+ char sorted[strlen(queryParams) * 2];
|
|
|
sorted[0] = '\0';
|
|
|
- sort_query_string(queryParams, sorted, sortedLen);
|
|
|
+ sort_query_string(queryParams, sorted, sizeof(sorted));
|
|
|
append(sorted);
|
|
|
- delete[] sorted; // WINSCP (heap allocation)
|
|
|
}
|
|
|
|
|
|
if (subResource && subResource[0]) {
|
|
|
@@ -967,15 +962,13 @@ static S3Status compose_auth_header(const RequestParams *params,
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
- char * canonicalRequest = new char[canonicalRequestLen]; // WINSCP (heap allocation)
|
|
|
+ char canonicalRequest[canonicalRequestLen];
|
|
|
|
|
|
-// WINSCP (heap allocation)
|
|
|
#define buf_append(buf, format, ...) \
|
|
|
- len += snprintf(&(buf[len]), size - len, \
|
|
|
+ len += snprintf(&(buf[len]), sizeof(buf) - len, \
|
|
|
format, __VA_ARGS__)
|
|
|
|
|
|
canonicalRequest[0] = '\0';
|
|
|
- int size = canonicalRequestLen; // WINSCP
|
|
|
buf_append(canonicalRequest, "%s\n", httpMethod);
|
|
|
buf_append(canonicalRequest, "%s\n", values->canonicalURI);
|
|
|
buf_append(canonicalRequest, "%s\n", values->canonicalQueryString);
|
|
|
@@ -996,9 +989,7 @@ static S3Status compose_auth_header(const RequestParams *params,
|
|
|
const unsigned char *rqstData = (const unsigned char*) canonicalRequest;
|
|
|
SHA256(rqstData, strlen(canonicalRequest), canonicalRequestHash);
|
|
|
#endif
|
|
|
- delete[] canonicalRequest; // WINSCP
|
|
|
char canonicalRequestHashHex[2 * S3_SHA256_DIGEST_LENGTH + 1];
|
|
|
- size = sizeof(canonicalRequestHashHex); // WINSCP
|
|
|
canonicalRequestHashHex[0] = '\0';
|
|
|
int i = 0;
|
|
|
for (; i < S3_SHA256_DIGEST_LENGTH; i++) {
|
|
|
@@ -1010,15 +1001,14 @@ static S3Status compose_auth_header(const RequestParams *params,
|
|
|
awsRegion = params->bucketContext.authRegion;
|
|
|
}
|
|
|
const char * service = (params->bucketContext.service != NULL) ? params->bucketContext.service : S3_SERVICE; // WINSCP
|
|
|
- int scopeSize = 8 + strlen(awsRegion) + strlen(service) + sizeof("///aws4_request"); // WINSCP
|
|
|
- char * scope = new char[scopeSize]; // WINSCP
|
|
|
- snprintf(scope, scopeSize, "%.8s/%s/%s/aws4_request",
|
|
|
+ int scopeSize = 8 + strlen(awsRegion) + strlen(service) + sizeof("///aws4_request") + 1; // WINSCP
|
|
|
+ char scope[scopeSize]; // WINSCP
|
|
|
+ snprintf(scope, sizeof(scope), "%.8s/%s/%s/aws4_request",
|
|
|
values->requestDateISO8601, awsRegion, service); // WINSCP
|
|
|
|
|
|
- const int stringToSignLen = 17 + 17 + sizeof(values->requestDateISO8601) +
|
|
|
- scopeSize - 1 + sizeof(canonicalRequestHashHex) + 1; // WINSCP (heap allocation)
|
|
|
- char * stringToSign = new char[stringToSignLen];
|
|
|
- snprintf(stringToSign, stringToSignLen, "AWS4-HMAC-SHA256\n%s\n%s\n%s",
|
|
|
+ char stringToSign[17 + 17 + sizeof(values->requestDateISO8601) +
|
|
|
+ sizeof(scope) + sizeof(canonicalRequestHashHex) + 1];
|
|
|
+ snprintf(stringToSign, sizeof(stringToSign), "AWS4-HMAC-SHA256\n%s\n%s\n%s",
|
|
|
values->requestDateISO8601, scope, canonicalRequestHashHex);
|
|
|
|
|
|
#ifdef SIGNATURE_DEBUG
|
|
|
@@ -1026,9 +1016,8 @@ static S3Status compose_auth_header(const RequestParams *params,
|
|
|
#endif
|
|
|
|
|
|
const char *secretAccessKey = params->bucketContext.secretAccessKey;
|
|
|
- const int accessKeyLen = strlen(secretAccessKey) + 5; // WINSCP (heap allocation)
|
|
|
- char * accessKey = new char[accessKeyLen];
|
|
|
- snprintf(accessKey, accessKeyLen, "AWS4%s", secretAccessKey);
|
|
|
+ char accessKey[strlen(secretAccessKey) + 5];
|
|
|
+ snprintf(accessKey, sizeof(accessKey), "AWS4%s", secretAccessKey);
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
unsigned char dateKey[S3_SHA256_DIGEST_LENGTH];
|
|
|
@@ -1071,11 +1060,8 @@ static S3Status compose_auth_header(const RequestParams *params,
|
|
|
(const unsigned char*) stringToSign, strlen(stringToSign),
|
|
|
finalSignature, NULL);
|
|
|
#endif
|
|
|
- delete[] accessKey; // WINSCP
|
|
|
- delete[] stringToSign; // WINSCP
|
|
|
|
|
|
len = 0;
|
|
|
- size = sizeof(values->requestSignatureHex); // WINSCP
|
|
|
values->requestSignatureHex[0] = '\0';
|
|
|
for (i = 0; i < S3_SHA256_DIGEST_LENGTH; i++) {
|
|
|
buf_append(values->requestSignatureHex, "%02x", finalSignature[i]);
|
|
|
@@ -1084,7 +1070,6 @@ static S3Status compose_auth_header(const RequestParams *params,
|
|
|
snprintf(values->authCredential, sizeof(values->authCredential),
|
|
|
"%s/%.8s/%s/%s/aws4_request", params->bucketContext.accessKeyId,
|
|
|
values->requestDateISO8601, awsRegion, service); // WINSCP
|
|
|
- delete[] scope; // WINSCP
|
|
|
|
|
|
snprintf(values->authorizationHeader,
|
|
|
sizeof(values->authorizationHeader),
|
|
|
@@ -1823,11 +1808,8 @@ S3Status S3_generate_authenticated_query_string
|
|
|
expires = MAX_EXPIRES;
|
|
|
}
|
|
|
|
|
|
- // WinSCP
|
|
|
RequestParams params =
|
|
|
- { http_request_method_to_type(httpMethod),
|
|
|
- { bucketContext->hostName, bucketContext->bucketName, bucketContext->protocol, bucketContext->uriStyle, bucketContext->accessKeyId, bucketContext->secretAccessKey, bucketContext->securityToken, bucketContext->authRegion },
|
|
|
- key, NULL,
|
|
|
+ { http_request_method_to_type(httpMethod), *bucketContext, key, NULL,
|
|
|
resource,
|
|
|
NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0};
|
|
|
|