base64_encode: fix input and output length types

This commit is contained in:
bptato
2021-02-03 10:41:20 +01:00
parent d277e80771
commit 5cd5a1735a
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -2009,18 +2009,19 @@ static char Base64Table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char * char *
base64_encode(const unsigned char *src, int len) base64_encode(const unsigned char *src, size_t len)
{ {
unsigned char *w, *at; unsigned char *w, *at;
const unsigned char *in, *endw; const unsigned char *in, *endw;
int j, k; int j;
size_t k;
k = len; k = len;
if (k % 3) if (k % 3)
k += 3 - (k % 3); k += 3 - (k % 3);
k = k / 3 * 4; k = k / 3 * 4;
if (k < len) if (k + 1 < len)
return NULL; return NULL;
w = GC_MALLOC_ATOMIC(k + 1); w = GC_MALLOC_ATOMIC(k + 1);
+1 -1
View File
@@ -829,4 +829,4 @@ void srand48(long);
long lrand48(void); long lrand48(void);
#endif #endif
extern char *base64_encode(const unsigned char *src, int len); extern char *base64_encode(const unsigned char *src, size_t len);