mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-18 13:16:58 +02:00
Patches from Yocto: https://git.openembedded.org/meta-openembedded/plain/meta-oe/recipes-support/libb64/libb64/ And upstream master
38 lines
1.2 KiB
Diff
38 lines
1.2 KiB
Diff
From a28e18ed374aee315d5a96a2f9275b7998e70558 Mon Sep 17 00:00:00 2001
|
|
From: Thilo Schulz <thilo@tjps.eu>
|
|
Date: Sat, 8 Feb 2020 15:27:07 +0100
|
|
Subject: [PATCH] Fix off by one bug reported by Gabriel Kihlman (#4)
|
|
|
|
---
|
|
src/cdecode.c | 15 ++++++++++-----
|
|
1 file changed, 10 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/cdecode.c b/src/cdecode.c
|
|
index 71edf75..73b6747 100644
|
|
--- a/src/cdecode.c
|
|
+++ b/src/cdecode.c
|
|
@@ -21,11 +21,16 @@ size_t base64_decode_maxlength(size_t encode_len)
|
|
int base64_decode_value(signed char value_in)
|
|
{
|
|
static const signed char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
|
|
- static const char decoding_size = sizeof(decoding);
|
|
- if (value_in < 43) return -1;
|
|
- value_in -= 43;
|
|
- if (value_in > decoding_size) return -1;
|
|
- return decoding[(int)value_in];
|
|
+
|
|
+ if (value_in < (signed char) '+')
|
|
+ return -1;
|
|
+
|
|
+ value_in -= (signed char) '+';
|
|
+
|
|
+ if (value_in >= (signed char) (sizeof(decoding) / sizeof(*decoding)) )
|
|
+ return -1;
|
|
+
|
|
+ return decoding[value_in];
|
|
}
|
|
|
|
void base64_init_decodestate(base64_decodestate* state_in)
|
|
--
|
|
2.45.1
|
|
|