Merge pull request #1436 from ggtakec/fix_code

Fixed signature error due to case of hex string
This commit is contained in:
Takeshi Nakatani 2020-10-03 03:44:49 +09:00 committed by GitHub
commit be308e9d11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -163,7 +163,7 @@ std::string urlEncode(const std::string &s)
result += c;
}else{
result += "%";
result += s3fs_hex(&c, 1);
result += s3fs_hex(&c, 1, false);
}
}
return result;
@ -193,7 +193,7 @@ std::string urlEncode2(const std::string &s)
result += c;
}else{
result += "%";
result += s3fs_hex(&c, 1);
result += s3fs_hex(&c, 1, false);
}
}
return result;
@ -373,9 +373,12 @@ bool convert_unixtime_from_option_arg(const char* argv, time_t& unixtime)
return true;
}
std::string s3fs_hex(const unsigned char* input, size_t length)
std::string s3fs_hex(const unsigned char* input, size_t length, bool lower)
{
static const char hexAlphabet[] = "0123456789abcdef";
static const char hexLower[] = "0123456789abcdef";
static const char hexUpper[] = "0123456789ABCDEF";
const char* hexAlphabet = (lower ? hexLower : hexUpper);
std::string hex;
for(size_t pos = 0; pos < length; ++pos){
hex += hexAlphabet[input[pos] / 16];

View File

@ -92,7 +92,7 @@ bool get_keyword_value(std::string& target, const char* keyword, std::string& va
//
// For binary string
//
std::string s3fs_hex(const unsigned char* input, size_t length);
std::string s3fs_hex(const unsigned char* input, size_t length, bool lower = true);
char* s3fs_base64(const unsigned char* input, size_t length);
unsigned char* s3fs_decode64(const char* input, size_t* plength);