The following issues were found
src/api/wordstrboxrenderer.cpp
1 issues
Line: 84
Column: 3
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
wordstr_box_str += "\n";
}
char *ret = new char[wordstr_box_str.length() + 1];
strcpy(ret, wordstr_box_str.c_str());
delete res_it;
return ret;
}
/**********************************************************************
Reported by FlawFinder.
src/arch/simddetect.cpp
1 issues
Line: 244
Column: 32
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
#endif
}
const char *dotproduct_env = getenv("DOTPRODUCT");
if (dotproduct_env != nullptr) {
// Override automatic settings by value from environment variable.
dotproduct = dotproduct_env;
Update();
}
Reported by FlawFinder.
src/ccmain/applybox.cpp
1 issues
Line: 524
Column: 27
CWE codes:
126
for (int step = 0; *utf8 != '\0'; utf8 += step) {
const char *next_space = strchr(utf8, ' ');
if (next_space == nullptr) {
next_space = utf8 + strlen(utf8);
}
step = next_space - utf8;
UNICHAR_ID class_id = unicharset.unichar_to_id(utf8, step);
if (class_id == INVALID_UNICHAR_ID) {
return false;
Reported by FlawFinder.
src/ccmain/equationdetect.cpp
1 issues
Line: 1392
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
void EquationDetect::GetOutputTiffName(const char *name, std::string &image_name) const {
ASSERT_HOST(name);
char page[50];
snprintf(page, sizeof(page), "%04d", page_count_);
image_name = (lang_tesseract_->imagebasename) + page + name + ".tif";
}
void EquationDetect::PaintSpecialTexts(const std::string &outfile) const {
Reported by FlawFinder.
src/ccmain/osdetect.cpp
1 issues
Line: 508
Column: 11
CWE codes:
126
++script_count;
}
if (strlen(prev_unichar) == 1) {
if (unichar[0] >= '0' && unichar[0] <= '9') {
break;
}
}
Reported by FlawFinder.
src/ccmain/reject.cpp
1 issues
Line: 308
Column: 14
CWE codes:
126
word = word_res->best_choice->unichar_string().c_str();
lengths = word_res->best_choice->unichar_lengths().c_str();
word_len = strlen(lengths);
/*
If there are no occurrences of the conflict set characters then the word
is OK.
*/
if (strpbrk(word, conflict_set_I_l_1.c_str()) == nullptr) {
Reported by FlawFinder.
src/ccmain/resultiterator.cpp
1 issues
Line: 686
Column: 3
CWE codes:
120
}
int length = text.length() + 1;
char *result = new char[length];
strncpy(result, text.c_str(), length);
return result;
}
std::vector<std::vector<std::vector<std::pair<const char *, float>>>>
*ResultIterator::GetRawLSTMTimesteps() const {
if (it_->word() != nullptr) {
Reported by FlawFinder.
src/ccstruct/blread.cpp
1 issues
Line: 51
Column: 15
CWE codes:
362
BLOCK_IT block_it = blocks; // block iterator
name += UNLV_EXT; // add extension
if ((pdfp = fopen(name.c_str(), "rb")) == nullptr) {
return false; // didn't read one
} else {
while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
// make rect block
block = new BLOCK(name.c_str(), true, 0, 0, static_cast<int16_t>(x),
Reported by FlawFinder.
src/ccstruct/coutln.cpp
1 issues
Line: 1032
Column: 7
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
memmove(&steps[0], &source.steps[0], step_mem());
if (source.offsets != nullptr) {
offsets = new EdgeOffset[stepcount];
memcpy(offsets, source.offsets, stepcount * sizeof(*offsets));
}
}
return *this;
}
Reported by FlawFinder.
src/ccstruct/fontinfo.cpp
1 issues
Line: 158
Column: 18
CWE codes:
126
}
bool write_info(FILE *f, const FontInfo &fi) {
int32_t size = strlen(fi.name);
return tesseract::Serialize(f, &size) && tesseract::Serialize(f, &fi.name[0], size) &&
tesseract::Serialize(f, &fi.properties);
}
bool read_spacing_info(TFile *f, FontInfo *fi) {
Reported by FlawFinder.