Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/BmpFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,16 @@ void BmpFile::readdata ()
paddinglength = 4 - (linelength % 4) ;
}

unsigned long long total_bytes_needed = (unsigned long long)height * (unsigned long long)linelength;

const unsigned long long MAX_ALLOWED_BYTES = 500ULL * 1024ULL * 1024ULL;

if (total_bytes_needed > MAX_ALLOWED_BYTES) {
fprintf(stderr, "[!] SECURITY ERROR: BMP file requires %llu bytes, which exceeds the limit of %llu bytes.\n", total_bytes_needed, MAX_ALLOWED_BYTES);
fprintf(stderr, "[!] Execution aborted to prevent Memory Exhaustion/DoS.\n");
exit(1);
}

BitmapData.resize (height * linelength) ;
for (unsigned long line = 0 ; line < height ; line++) {
for (unsigned long posinline = 0 ; posinline < linelength ; posinline++) {
Expand Down
2 changes: 1 addition & 1 deletion src/Embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void Embedder::embed ()
cvrstring = "\"" + Args.CvrFn.getValue() + "\"" ;
}
char buf[200] ;
sprintf (buf, _("embedding %s in %s..."), embstring.c_str(), cvrstring.c_str()) ;
snprintf(buf, sizeof(buf), _("embedding %s in %s..."), embstring.c_str(), cvrstring.c_str());

prout = new ProgressOutput (std::string(buf)) ;
}
Expand Down