The following issues were found
src/ccstruct/ocrpara.cpp
1 issues
Line: 86
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
}
std::string ParagraphModel::ToString() const {
char buffer[200];
const char *alignment = ParagraphJustificationToString(justification_);
snprintf(buffer, sizeof(buffer), "margin: %d, first_indent: %d, body_indent: %d, alignment: %s",
margin_, first_indent_, body_indent_, alignment);
return std::string(buffer);
}
Reported by FlawFinder.
src/ccstruct/rejctmap.cpp
1 issues
Line: 117
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 REJMAP::print(FILE *fp) const {
int i;
char buff[512];
for (i = 0; i < len; i++) {
buff[i] = ptr[i].display_char();
}
buff[i] = '\0';
Reported by FlawFinder.
src/ccstruct/statistc.cpp
1 issues
Line: 322
Column: 3
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
result.add(entry + rangemin_, count);
}
total_count_ = result.total_count_;
memcpy(buckets_, result.buckets_, entrycount * sizeof(buckets_[0]));
}
/**********************************************************************
* STATS::cluster
*
Reported by FlawFinder.
src/ccutil/params.cpp
1 issues
Line: 53
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
bool ParamUtils::ReadParamsFromFp(SetParamConstraint constraint, TFile *fp,
ParamsVectors *member_params) {
char line[MAX_PATH]; // input line
bool anyerr = false; // true if any error
bool foundit; // found parameter
char *valptr; // value field
while (fp->FGets(line, MAX_PATH) != nullptr) {
Reported by FlawFinder.
src/classify/adaptmatch.cpp
1 issues
Line: 466
Column: 12
CWE codes:
362
if (AdaptedTemplates != nullptr && classify_enable_adaptive_matcher &&
classify_save_adapted_templates) {
Filename = imagefile + ADAPT_TEMPLATE_SUFFIX;
File = fopen(Filename.c_str(), "wb");
if (File == nullptr) {
tprintf("Unable to save adapted templates to %s!\n", Filename.c_str());
} else {
tprintf("\nSaving adapted templates to %s ...", Filename.c_str());
fflush(stdout);
Reported by FlawFinder.
src/classify/blobclass.cpp
1 issues
Line: 64
Column: 14
CWE codes:
362
bool result = false;
std::string tr_filename = filename;
tr_filename += ".tr";
FILE *fp = fopen(tr_filename.c_str(), "wb");
if (fp) {
result = tesseract::Serialize(fp, &tr_file_data_[0], tr_file_data_.length());
fclose(fp);
}
tr_file_data_.resize(0);
Reported by FlawFinder.
src/classify/cutoffs.cpp
1 issues
Line: 54
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
}
const int kMaxLineSize = 100;
char line[kMaxLineSize];
while (fp->FGets(line, kMaxLineSize) != nullptr) {
std::string Class;
CLASS_ID ClassId;
std::istringstream stream(line);
stream.imbue(std::locale::classic());
Reported by FlawFinder.
src/classify/featdefs.cpp
1 issues
Line: 174
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
*/
CHAR_DESC_STRUCT *ReadCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, FILE *File) {
int NumSetsToRead;
char ShortName[FEAT_NAME_SIZE];
int Type;
ASSERT_HOST(tfscanf(File, "%d", &NumSetsToRead) == 1);
ASSERT_HOST(NumSetsToRead >= 0);
ASSERT_HOST(NumSetsToRead <= FeatureDefs.NumFeatureTypes);
Reported by FlawFinder.
src/dict/dict.cpp
1 issues
Line: 700
Column: 27
CWE codes:
362
if (save_doc_words) {
std::string filename(getCCUtil()->imagefile);
filename += ".doc";
FILE *doc_word_file = fopen(filename.c_str(), "a");
if (doc_word_file == nullptr) {
tprintf("Error: Could not open file %s\n", filename.c_str());
ASSERT_HOST(doc_word_file);
}
fprintf(doc_word_file, "%s\n", best_choice.debug_string().c_str());
Reported by FlawFinder.
src/dict/permdawg.cpp
1 issues
Line: 113
Column: 38
CWE codes:
362
}
if (strcmp(output_ambig_words_file.c_str(), "") != 0) {
if (output_ambig_words_file_ == nullptr) {
output_ambig_words_file_ = fopen(output_ambig_words_file.c_str(), "wb+");
if (output_ambig_words_file_ == nullptr) {
tprintf("Failed to open output_ambig_words_file %s\n", output_ambig_words_file.c_str());
exit(1);
}
std::string word_str;
Reported by FlawFinder.