Skip to content

Commit

Permalink
Fix CID 1164710 (Copy into fixed size buffer)
Browse files Browse the repository at this point in the history
As null_script never changes, it is not necessary to allocate it in
each class instance. Change this, too.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Apr 23, 2018
1 parent d3f6382 commit cb77067
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ccutil/unicharset.cpp
Expand Up @@ -83,6 +83,8 @@ const char* UNICHARSET::kSpecialUnicharCodes[SPECIAL_UNICHAR_CODES_COUNT] = {
"|Broken|0|1"
};

const char* UNICHARSET::null_script = "NULL";

UNICHARSET::UNICHAR_PROPERTIES::UNICHAR_PROPERTIES() {
Init();
}
Expand Down Expand Up @@ -175,8 +177,7 @@ UNICHARSET::UNICHARSET() :
size_used(0),
size_reserved(0),
script_table(nullptr),
script_table_size_used(0),
null_script("NULL") {
script_table_size_used(0) {
clear();
for (int i = 0; i < SPECIAL_UNICHAR_CODES_COUNT; ++i) {
unichar_insert(kSpecialUnicharCodes[i]);
Expand Down Expand Up @@ -803,7 +804,7 @@ bool UNICHARSET::load_via_fgets(
unsigned int properties;
char script[64];

strcpy(script, null_script);
strncpy(script, null_script, sizeof(script));
int min_bottom = 0;
int max_bottom = UINT8_MAX;
int min_top = 0;
Expand Down
2 changes: 1 addition & 1 deletion ccutil/unicharset.h
Expand Up @@ -1006,6 +1006,7 @@ class UNICHARSET {
// The substitutions clean up text that should exists for rendering of
// synthetic data, but not in the recognition set.
static const char* kCleanupMaps[][2];
static const char* null_script;

UNICHAR_SLOT* unichars;
UNICHARMAP ids;
Expand All @@ -1014,7 +1015,6 @@ class UNICHARSET {
char** script_table;
int script_table_size_used;
int script_table_size_reserved;
const char* null_script;
// True if the unichars have their tops/bottoms set.
bool top_bottom_set_;
// True if the unicharset has significant upper/lower case chars.
Expand Down

0 comments on commit cb77067

Please sign in to comment.