From 7497f2a49fe3b9667a2dce0deede7909688be285 Mon Sep 17 00:00:00 2001 From: Ilya Grebnov Date: Wed, 23 Nov 2022 20:37:28 -0800 Subject: [PATCH] bsc 3.2.5 --- CHANGES | 4 ++++ README | 4 ++-- VERSION | 2 +- bsc.cpp | 4 ++-- libbsc/lzp/lzp.cpp | 17 ++++++++++------- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index fbdf96d..9c2b048 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +Changes in 3.2.5 (November, 23 2022) +- Fixed data corruption issue in LZP encoder. +- Due to these fix, an upgrade to this version is strongly recommended. + Changes in 3.2.4 (18 January, 18 2022) - Improved performance for AArch64 (ARM64) platform. diff --git a/README b/README index 1e7d0f5..775a4ab 100644 --- a/README +++ b/README @@ -10,7 +10,7 @@ block-sorting data compression algorithms. libbsc is a library based on bsc, it uses the same algorithms as bsc and enables you to compress memory blocks. -Copyright (c) 2009-2021 Ilya Grebnov +Copyright (c) 2009-2022 Ilya Grebnov See file AUTHORS for a full list of contributors. @@ -21,7 +21,7 @@ See the bsc and libbsc web site: Software License: ----------------- -Copyright (c) 2009-2021 Ilya Grebnov +Copyright (c) 2009-2022 Ilya Grebnov Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/VERSION b/VERSION index 9b7a431..448ada3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.4 \ No newline at end of file +3.2.5 \ No newline at end of file diff --git a/bsc.cpp b/bsc.cpp index 9aebc91..250b6f0 100644 --- a/bsc.cpp +++ b/bsc.cpp @@ -851,8 +851,8 @@ void ProcessCommandline(int argc, char * argv[]) int main(int argc, char * argv[]) { - fprintf(stdout, "This is bsc, Block Sorting Compressor. Version 3.2.4. 18 January 2022.\n"); - fprintf(stdout, "Copyright (c) 2009-2021 Ilya Grebnov .\n\n"); + fprintf(stdout, "This is bsc, Block Sorting Compressor. Version 3.2.5. 23 November 2022.\n"); + fprintf(stdout, "Copyright (c) 2009-2022 Ilya Grebnov .\n\n"); #if defined(_OPENMP) && defined(__INTEL_COMPILER) diff --git a/libbsc/lzp/lzp.cpp b/libbsc/lzp/lzp.cpp index 07cc7e9..93f530c 100644 --- a/libbsc/lzp/lzp.cpp +++ b/libbsc/lzp/lzp.cpp @@ -541,13 +541,16 @@ int bsc_lzp_encode_block(const unsigned char * input, const unsigned char * inpu if (int * lookup = (int *)bsc_zero_malloc((int)(1 << hashSize) * sizeof(int))) { #if defined(LIBBSC_ALLOW_UNALIGNED_ACCESS) && (defined(__x86_64__) || defined(__aarch64__)) - result = (minLen == 1 * (int)sizeof(unsigned int ) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_small (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1) : result; - result = (minLen == 1 * (int)sizeof(unsigned long long) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_small (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1) : result; - result = (minLen == 2 * (int)sizeof(unsigned long long) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_small2x(input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1) : result; - result = (minLen <= 2 * (int)sizeof(unsigned int ) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_medium (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result; - result = (minLen <= 2 * (int)sizeof(unsigned long long) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_medium (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result; - - result = result == LIBBSC_NOT_ENOUGH_MEMORY ? bsc_lzp_encode_large(input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result; + if (hashSize <= 17) + { + result = (minLen == 1 * (int)sizeof(unsigned int ) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_small (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1) : result; + result = (minLen == 1 * (int)sizeof(unsigned long long) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_small (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1) : result; + result = (minLen == 2 * (int)sizeof(unsigned long long) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_small2x(input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1) : result; + result = (minLen <= 2 * (int)sizeof(unsigned int ) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_medium (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result; + result = (minLen <= 2 * (int)sizeof(unsigned long long) && result == LIBBSC_NOT_ENOUGH_MEMORY) ? bsc_lzp_encode_medium (input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result; + + result = result == LIBBSC_NOT_ENOUGH_MEMORY ? bsc_lzp_encode_large(input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result; + } #endif result = result == LIBBSC_NOT_ENOUGH_MEMORY ? bsc_lzp_encode_generic(input, inputEnd, output, outputEnd, lookup, (int)(1 << hashSize) - 1, minLen) : result;