Skip to content

Commit da390aa

Browse files
committed
fix: 32bit be decoding
1 parent 3549efa commit da390aa

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
22
if (POLICY CMP0048)
33
cmake_policy(SET CMP0048 NEW)
44
endif (POLICY CMP0048)
5-
project(base16384 VERSION 2.2.3)
5+
project(base16384 VERSION 2.2.4)
66

77
add_executable(base16384_b base16384.c)
88

base1432.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ int base16384_decode(const char* data, int dlen, char* buf, int blen) {
194194
if(offset--) {
195195
buf[i] = (sum & 0x0f000000) >> 20;
196196
// 这里有读取越界
197-
sum = vals[n];
197+
#ifdef WORDS_BIGENDIAN
198+
sum = __builtin_bswap32(vals[n]);
199+
#else
200+
sum = vals[n];
201+
#endif
198202
sum -= 0x0000004e;
199203
buf[i++] |= (sum & 0x0000003c) >> 2;
200204
if(offset--) {

base16384.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ unsigned long get_start_ms() {
3939
#endif
4040

4141
static void print_usage() {
42-
puts("Copyright (c) 2022-2023 Fumiama Minamoto.\nBase16384 2.2.3 (May 18th 2023). Usage:");
42+
puts("Copyright (c) 2022-2023 Fumiama Minamoto.\nBase16384 2.2.4 (July 23rd 2023). Usage:");
4343
puts("base16384 [-edt] [inputfile] [outputfile]");
4444
puts(" -e\t\tencode");
4545
puts(" -d\t\tdecode");

0 commit comments

Comments
 (0)