From da390aa973dc7aab0a7d2e1a94e4e74aa4823d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 23 Jul 2023 22:52:10 +0800 Subject: [PATCH] fix: 32bit be decoding --- CMakeLists.txt | 2 +- base1432.c | 6 +++++- base16384.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57e01ac..e56b1f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/base1432.c b/base1432.c index faca57e..86d9080 100644 --- a/base1432.c +++ b/base1432.c @@ -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--) { diff --git a/base16384.c b/base16384.c index 73e2ae0..e6e04b0 100644 --- a/base16384.c +++ b/base16384.c @@ -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");