aboutsummaryrefslogtreecommitdiffstats
path: root/etc.c
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-02-03 09:41:20 +0000
committerbptato <nincsnevem662@gmail.com>2021-02-03 09:41:20 +0000
commit5cd5a1735af6a5c649c2d6699f8022e722fff170 (patch)
tree695975ed5d417b6707edabd7a3d197ef1a1c0993 /etc.c
parentSome cleanup for base64_encode (diff)
downloadw3m-5cd5a1735af6a5c649c2d6699f8022e722fff170.tar.gz
w3m-5cd5a1735af6a5c649c2d6699f8022e722fff170.zip
base64_encode: fix input and output length types
Diffstat (limited to '')
-rw-r--r--etc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/etc.c b/etc.c
index 7fabd03..0c3a004 100644
--- a/etc.c
+++ b/etc.c
@@ -2009,18 +2009,19 @@ static char Base64Table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *
-base64_encode(const unsigned char *src, int len)
+base64_encode(const unsigned char *src, size_t len)
{
unsigned char *w, *at;
const unsigned char *in, *endw;
- int j, k;
+ int j;
+ size_t k;
k = len;
if (k % 3)
k += 3 - (k % 3);
k = k / 3 * 4;
- if (k < len)
+ if (k + 1 < len)
return NULL;
w = GC_MALLOC_ATOMIC(k + 1);