tesseract/src/classify
Stefan Weil 3452c8ebee Fix out-of-bounds writes in Classify::ReadNewCutoffs
The function did not correctly read Chinese unichars into the local
Class variable if the locale was set to de_DE.UTF-8 (or other
incompatible locales). That resulted in a wrong ClassId which was
used to write into the Cutoffs array without checking for valid bounds.

On macOS the result was a runtime error in baseapi_test (see GitHub
issue #1250):

    [ RUN      ] TesseractTest.InitConfigOnlyTest
    baseapi_test(21845,0x1134c45c0) malloc: *** error for object 0x927f96c28005e0: pointer being freed was not allocated
    baseapi_test(21845,0x1134c45c0) malloc: *** set a breakpoint in malloc_error_break to debug

Replacing sscanf by std::istringstream fixes that.
Add also an assertion to catch future out-of-bounds writes.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-05-18 13:59:48 +02:00
..
adaptive.cpp Modernize code by replacing C type casts 2019-04-07 09:04:51 +02:00
adaptive.h Modernize and format code 2019-04-03 21:02:23 +02:00
adaptmatch.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
blobclass.cpp Use tesseract::Serialize, tesseract::DeSerialize 2018-07-18 11:19:37 +02:00
blobclass.h blobclass: Remove unused macros 2019-03-31 17:36:46 +02:00
classify.cpp Remove unused config variable tessedit_single_match 2019-03-31 17:38:35 +02:00
classify.h Remove unused config variable tessedit_single_match 2019-03-31 17:38:35 +02:00
cluster.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
cluster.h Modernize and format code 2019-04-03 21:02:23 +02:00
clusttool.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
clusttool.h clusttool: Remove unused code and some global functions 2019-05-04 14:34:34 +02:00
cutoffs.cpp Fix out-of-bounds writes in Classify::ReadNewCutoffs 2019-05-18 13:59:48 +02:00
cutoffs.h Remove tab character in source files 2018-10-12 11:31:10 +02:00
errorcounter.cpp Modernize C++ loops 2019-03-26 08:38:21 +01:00
errorcounter.h Use default keyword instead of empty ctors/dtors. 2018-05-21 13:35:46 +03:00
featdefs.cpp Modernize code by replacing C type casts 2019-04-07 09:04:51 +02:00
featdefs.h Remove tab character in source files 2018-10-12 11:31:10 +02:00
float2int.cpp Fix whitespace issues 2018-08-01 13:19:52 +02:00
float2int.h Remove tab character in source files 2018-10-12 11:31:10 +02:00
fpoint.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
fpoint.h Remove BOOL8, TRUE, FALSE from host.h 2019-03-31 18:27:20 +02:00
intfeaturedist.cpp Small enhancements (adding const, etc.) 2018-05-19 23:07:28 +03:00
intfeaturedist.h Fix line endings 2018-04-25 19:04:50 +02:00
intfeaturemap.cpp Move sources into src dir. Update build scripts. 2018-04-25 11:02:54 +03:00
intfeaturemap.h Fix line endings 2018-04-25 19:04:50 +02:00
intfeaturespace.cpp IntFeatureSpace: Remove unused DeSerialize method 2018-07-18 09:56:43 +02:00
intfeaturespace.h IntFeatureSpace: Remove unused DeSerialize method 2018-07-18 09:56:43 +02:00
intfx.cpp Fix compiler warnings [-Wmissing-prototypes] 2018-07-05 16:03:02 +02:00
intfx.h Rename all C-style headers (e.g. <stdio.h>) to C++ style (<cstdio>). 2018-05-20 00:52:04 +03:00
intmatcher.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
intmatcher.h classify: Replace BOOL8, TRUE, FALSE by bool, true, false 2019-03-31 17:55:48 +02:00
intproto.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
intproto.h Modernize and format code 2019-04-03 21:02:23 +02:00
kdtree.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
kdtree.h Modernize and format code 2019-04-03 21:02:23 +02:00
Makefile.am Fix whitespace issues 2018-08-01 13:19:52 +02:00
mastertrainer.cpp Modernize C++ code using auto 2019-03-26 07:55:08 +01:00
mastertrainer.h Fix typo in comments and variable name 2018-08-14 16:20:27 +02:00
mf.cpp Modernize code by replacing C type casts 2019-04-07 09:04:51 +02:00
mf.h Remove tab character in source files 2018-10-12 11:31:10 +02:00
mfdefs.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
mfdefs.h Modernize and format code 2019-04-03 21:02:23 +02:00
mfoutline.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
mfoutline.h Modernize and format code 2019-04-03 21:02:23 +02:00
mfx.cpp Modernize code by replacing C type casts 2019-04-07 09:04:51 +02:00
mfx.h Fix compiler warnings [-Wmissing-prototypes] 2018-07-05 16:03:02 +02:00
normfeat.cpp Replace FLOAT32 by float data type 2018-07-02 13:29:39 +02:00
normfeat.h Replace FLOAT32 by float data type 2018-07-02 13:29:39 +02:00
normmatch.cpp Fix baseapi_test with locale de_DE.UTF-8 2019-05-16 20:23:24 +02:00
normmatch.h Remove tab character in source files 2018-10-12 11:31:10 +02:00
ocrfeatures.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
ocrfeatures.h classify: Replace BOOL8, TRUE, FALSE by bool, true, false 2019-03-31 17:55:48 +02:00
outfeat.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
outfeat.h Remove tab character in source files 2018-10-12 11:31:10 +02:00
picofeat.cpp Fix Doxygen comments for void functions 2019-05-16 20:19:01 +02:00
picofeat.h Replace FLOAT32 by float data type 2018-07-02 13:29:39 +02:00
protos.cpp Modernize code by replacing C type casts 2019-04-07 09:04:51 +02:00
protos.h protos: Remove several unused macros, functions and global variables 2018-12-13 21:32:56 +01:00
sampleiterator.cpp Fix file endings 2018-04-25 19:35:33 +02:00
sampleiterator.h Move sources into src dir. Update build scripts. 2018-04-25 11:02:54 +03:00
shapeclassifier.cpp Modernize C++ code using auto 2019-03-26 07:55:08 +01:00
shapeclassifier.h Use default keyword instead of empty ctors/dtors. 2018-05-21 13:35:46 +03:00
shapetable.cpp Modernize C++ code using auto 2019-03-26 07:55:08 +01:00
shapetable.h Modernize C++ code using auto 2019-03-26 07:55:08 +01:00
tessclassifier.cpp Small enhancements (adding const, etc.) 2018-05-19 23:07:28 +03:00
tessclassifier.h Modernize C++ code using override 2019-03-26 07:37:52 +01:00
trainingsample.cpp Modernize C++ code using auto 2019-03-26 07:55:08 +01:00
trainingsample.h Fix CID 1164703 (Untrusted value as argument) 2018-07-06 16:11:10 +02:00
trainingsampleset.cpp Fix CID 1395116 ('Constant' variable guards dead code) 2018-08-22 13:55:37 +02:00
trainingsampleset.h Move sources into src dir. Update build scripts. 2018-04-25 11:02:54 +03:00