Skip to content

Commit

Permalink
Fix auth base64 computation when HMAC return string contains \0 chara…
Browse files Browse the repository at this point in the history
…cter
  • Loading branch information
vejmarie authored and wwmayer committed Oct 18, 2019
1 parent d0e1305 commit f911796
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Mod/Cloud/App/AppCloud.cpp
Expand Up @@ -255,6 +255,7 @@ struct Cloud::AmzData *Cloud::ComputeDigestAmzS3v2(char *operation, char *data_t
char date_formatted[256];
char StringToSign[1024];
unsigned char *digest;
unsigned int HMACLength;
// Amazon S3 and Swift require the timezone to be define to GMT.
// As to simplify the conversion this is performed through the TZ
// environment variable and a call to localtime as to convert output of gettimeofday
Expand Down Expand Up @@ -292,8 +293,8 @@ struct Cloud::AmzData *Cloud::ComputeDigestAmzS3v2(char *operation, char *data_t
sprintf(StringToSign,"%s\n\n%s\n%s\n%s", operation, data_type, date_formatted, target);
// We have to use HMAC encoding and SHA1
digest=HMAC(EVP_sha1(),Secret,strlen(Secret),
(const unsigned char *)&StringToSign,strlen(StringToSign),NULL,NULL);
returnData->digest = Base::base64_encode(digest,strlen((const char *)digest));
(const unsigned char *)&StringToSign,strlen(StringToSign),NULL,&HMACLength);
returnData->digest = Base::base64_encode(digest,HMACLength);
strcpy(returnData->dateFormatted,date_formatted);
return returnData;

Expand Down

0 comments on commit f911796

Please sign in to comment.