:: commit 03596d49f0dcaa042c6b753483c7b364379ce0d5

Kamila Szewczyk <kspalaiologos@gmail.com> — 2022-05-16 08:51

parents: 3b9e24d329

add NEWS, mark bz3 memcpy issue as insignificant.

diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..5d22553
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,12 @@
+
+v1.1.2:
+* fix memory UB in libsais
+* restructure src/cm.c
+* block size check in src/libbz3.c
+* fix shift UB in lzp
+* -h/-v CLI switches
+* change maximum block size to ~512M
+
+v1.1.3:
+* fix a serious stdin/stdout CRLF bug on Windows that corrupted the data.
+* imply `-c` when a stream isn't opened thus preventing potential UB.
diff --git a/src/libbz3.c b/src/libbz3.c
index e24eb23..487274d 100644
--- a/src/libbz3.c
+++ b/src/libbz3.c
@@ -179,7 +179,6 @@ PUBLIC_API s32 bz3_encode_block(struct bz3_state * state, u8 * buffer, s32 data_
 
     state->last_error = BZ3_OK;
 
-    // XXX: Better solution
     if (b1 != buffer) memcpy(buffer, b1, data_size + overhead * 4 + 1);
 
     return data_size + overhead * 4 + 1;
@@ -283,7 +282,6 @@ PUBLIC_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_
         return -1;
     }
 
-    // XXX: Better solution
     if (b1 != buffer) memcpy(buffer, b1, size_src);
 
     if (crc32 != crc32sum(1, buffer, size_src)) {
diff --git a/src/lzp.c b/src/lzp.c
index af2a443..c19580d 100644
--- a/src/lzp.c
+++ b/src/lzp.c
@@ -1,7 +1,7 @@
 
 // Lempel Ziv Prediction code.
-// A heavily modified version of libbsc's LZP predictor. This one has single thread performance and provides better compression ratio.
-// It is also mostly UB-free and less brittle during AFL fuzzing.
+// A heavily modified version of libbsc's LZP predictor. This one has single thread performance and provides better
+// compression ratio. It is also mostly UB-free and less brittle during AFL fuzzing.
 
 #include <memory.h>
 #include <stdlib.h>
diff --git a/src/main.c b/src/main.c
index 4352591..16a11e3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,8 +26,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #if defined __MSVCRT__
-  #include <fcntl.h>
-  #include <io.h>
+    #include <fcntl.h>
+    #include <io.h>
 #endif
 
 #include "common.h"
@@ -151,13 +151,13 @@ int main(int argc, char * argv[]) {
 #endif
         return args_status;
     }
-    #ifndef O_BINARY
-		#define O_BINARY 0
-    #endif
-    #if defined(__MSVCRT__)
-		setmode(STDIN_FILENO, O_BINARY);
-		setmode(STDOUT_FILENO, O_BINARY);
-    #endif
+#ifndef O_BINARY
+    #define O_BINARY 0
+#endif
+#if defined(__MSVCRT__)
+    setmode(STDIN_FILENO, O_BINARY);
+    setmode(STDOUT_FILENO, O_BINARY);
+#endif
 
     if (mode != 2) {
         if (no_bz3_suffix || mode == 1) {
tab: 248 wrap: offon