diff options
author | Yann Ylavic <ylavic@apache.org> | 2022-06-23 11:40:06 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2022-06-23 11:40:06 +0000 |
commit | f5ca47dec5f3cb6a538bb4656f3c677cc566c148 (patch) | |
tree | 476f8cd3d1bf38d5980f830b8730ba3908d29f36 /crypto | |
parent | 9cc1fc7b565419e929929cbf906448a78ac3b03d (diff) | |
download | apr-f5ca47dec5f3cb6a538bb4656f3c677cc566c148.tar.gz |
crypto/blowfish: Fix wrnings for ints used as size_t.
* crypto/crypt_blowfish.c(BF_decode, BF_encode, _crypt_output_magic,
_crypt_blowfish_rn, _crypt_gensalt_blowfish_rn):
Use apr_size_t instead of int size.
* crypto/crypt_blowfish.c(_crypt_gensalt_blowfish_rn):
Fix conversion from 'unsigned long' to 'char'.
* crypto/crypt_blowfish.h():
Use apr_size_t instead of int size, and #include "apr.h".
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902195 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crypt_blowfish.c | 16 | ||||
-rw-r--r-- | crypto/crypt_blowfish.h | 12 |
2 files changed, 15 insertions, 13 deletions
diff --git a/crypto/crypt_blowfish.c b/crypto/crypt_blowfish.c index 3d306cf8d..fce474b0d 100644 --- a/crypto/crypt_blowfish.c +++ b/crypto/crypt_blowfish.c @@ -382,7 +382,7 @@ static unsigned char BF_atoi64[0x60] = { (dst) = tmp; \ } -static int BF_decode(BF_word *dst, const char *src, int size) +static int BF_decode(BF_word *dst, const char *src, apr_size_t size) { unsigned char *dptr = (unsigned char *)dst; unsigned char *end = dptr + size; @@ -406,7 +406,7 @@ static int BF_decode(BF_word *dst, const char *src, int size) return 0; } -static void BF_encode(char *dst, const BF_word *src, int size) +static void BF_encode(char *dst, const BF_word *src, apr_size_t size) { const unsigned char *sptr = (const unsigned char *)src; const unsigned char *end = sptr + size; @@ -642,7 +642,7 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, } static char *BF_crypt(const char *key, const char *setting, - char *output, int size, + char *output, apr_size_t size, BF_word min) { #if BF_ASM @@ -776,7 +776,7 @@ static char *BF_crypt(const char *key, const char *setting, return output; } -int _crypt_output_magic(const char *setting, char *output, int size) +int _crypt_output_magic(const char *setting, char *output, apr_size_t size) { if (size < 3) return -1; @@ -812,7 +812,7 @@ int _crypt_output_magic(const char *setting, char *output, int size) * setting. */ char *_crypt_blowfish_rn(const char *key, const char *setting, - char *output, int size) + char *output, apr_size_t size) { const char *test_key = "8b \xd0\xc1\xd2\xcf\xcc\xd8"; const char *test_setting = "$2a$00$abcdefghijklmnopqrstuu"; @@ -874,7 +874,7 @@ char *_crypt_blowfish_rn(const char *key, const char *setting, } char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count, - const char *input, int size, char *output, int output_size) + const char *input, apr_size_t size, char *output, apr_size_t output_size) { if (size < 16 || output_size < 7 + 22 + 1 || (count && (count < 4 || count > 17)) || @@ -891,8 +891,8 @@ char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count, output[1] = '2'; output[2] = prefix[2]; output[3] = '$'; - output[4] = '0' + count / 10; - output[5] = '0' + count % 10; + output[4] = '0' + (unsigned char)(count / 10); + output[5] = '0' + (unsigned char)(count % 10); output[6] = '$'; BF_encode(&output[7], (const BF_word *)input, 16); diff --git a/crypto/crypt_blowfish.h b/crypto/crypt_blowfish.h index 2ee0d8c1d..78248fa0e 100644 --- a/crypto/crypt_blowfish.h +++ b/crypto/crypt_blowfish.h @@ -17,11 +17,13 @@ #ifndef _CRYPT_BLOWFISH_H #define _CRYPT_BLOWFISH_H -extern int _crypt_output_magic(const char *setting, char *output, int size); +#include "apr.h" /* for apr_size_t */ + +extern int _crypt_output_magic(const char *setting, char *output, apr_size_t size); extern char *_crypt_blowfish_rn(const char *key, const char *setting, - char *output, int size); -extern char *_crypt_gensalt_blowfish_rn(const char *prefix, - unsigned long count, - const char *input, int size, char *output, int output_size); + char *output, apr_size_t size); +extern char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count, + const char *input, apr_size_t size, + char *output, apr_size_t output_size); #endif |