1
0
mirror of https://github.com/fumiama/base16384.git synced 2026-06-05 02:00:31 +08:00

fix: 32bit be decoding

This commit is contained in:
源文雨
2023-07-23 22:52:10 +08:00
parent 3549efad7a
commit da390aa973
3 changed files with 7 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
project(base16384 VERSION 2.2.3)
project(base16384 VERSION 2.2.4)
add_executable(base16384_b base16384.c)

View File

@@ -194,7 +194,11 @@ int base16384_decode(const char* data, int dlen, char* buf, int blen) {
if(offset--) {
buf[i] = (sum & 0x0f000000) >> 20;
// 这里有读取越界
sum = vals[n];
#ifdef WORDS_BIGENDIAN
sum = __builtin_bswap32(vals[n]);
#else
sum = vals[n];
#endif
sum -= 0x0000004e;
buf[i++] |= (sum & 0x0000003c) >> 2;
if(offset--) {

View File

@@ -39,7 +39,7 @@ unsigned long get_start_ms() {
#endif
static void print_usage() {
puts("Copyright (c) 2022-2023 Fumiama Minamoto.\nBase16384 2.2.3 (May 18th 2023). Usage:");
puts("Copyright (c) 2022-2023 Fumiama Minamoto.\nBase16384 2.2.4 (July 23rd 2023). Usage:");
puts("base16384 [-edt] [inputfile] [outputfile]");
puts(" -e\t\tencode");
puts(" -d\t\tdecode");