fix zero-terminator written to wrong position when encountering too long lines - fixes #490 v1.4.2

Sun, 10 Nov 2024 13:54:17 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 10 Nov 2024 13:54:17 +0100
changeset 76
d11c154e33e1
parent 75
ba4bc497c6a7
child 77
ee81f5f84a38

fix zero-terminator written to wrong position when encountering too long lines - fixes #490

Makefile file | annotate | diff | comparison | revisions
src/regex_parser.h file | annotate | diff | comparison | revisions
src/scanner.c file | annotate | diff | comparison | revisions
vs/cline.vcxproj file | annotate | diff | comparison | revisions
--- a/Makefile	Sun Nov 10 13:09:54 2024 +0100
+++ b/Makefile	Sun Nov 10 13:54:17 2024 +0100
@@ -21,7 +21,7 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-VERSION=1.4.1
+VERSION=1.4.2
 
 all: build config.mk FORCE
 	@cd src && $(MAKE) VERSION=$(VERSION)
--- a/src/regex_parser.h	Sun Nov 10 13:09:54 2024 +0100
+++ b/src/regex_parser.h	Sun Nov 10 13:54:17 2024 +0100
@@ -27,7 +27,7 @@
 #ifndef REGEX_PARSER_H_
 #define REGEX_PARSER_H_
 
-#define MAX_LINELENGTH           4096u
+#define MAX_LINELENGTH           4095u
 
 #include <sys/types.h>
 #include <stdbool.h>
--- a/src/scanner.c	Sun Nov 10 13:09:54 2024 +0100
+++ b/src/scanner.c	Sun Nov 10 13:54:17 2024 +0100
@@ -236,7 +236,7 @@
         bfile = false;
         bfile_reset(settings->bfileHeuristics);
         regex_parser_reset(settings->regex);
-        char line_buffer[MAX_LINELENGTH];
+        char line_buffer[MAX_LINELENGTH + 1];
         unsigned line_buffer_pos = 0;
 
         FILE *file = fopen(filelist->filename, "r");
@@ -279,7 +279,7 @@
                 line_buffer[line_buffer_pos] = (char) a;
                 line_buffer_pos++;
               } else {
-                line_buffer[line_buffer_pos - 1] = 0;
+                line_buffer[line_buffer_pos] = 0;
                 settings->confusing_lnlen = true;
               }
             }
--- a/vs/cline.vcxproj	Sun Nov 10 13:09:54 2024 +0100
+++ b/vs/cline.vcxproj	Sun Nov 10 13:54:17 2024 +0100
@@ -77,7 +77,7 @@
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
       <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>VERSION="1.4.1-win64-debug";_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>VERSION="1.4.2-win64-debug";_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ConformanceMode>true</ConformanceMode>
       <LanguageStandard_C>stdc11</LanguageStandard_C>
       <AdditionalIncludeDirectories>$(ProjectDir)include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -93,7 +93,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
       <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>VERSION="1.4.1-win64";NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>VERSION="1.4.2-win64";NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ConformanceMode>true</ConformanceMode>
       <LanguageStandard_C>stdc11</LanguageStandard_C>
       <CompileAs>CompileAsC</CompileAs>

mercurial