projects
/
fms.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
version 0.3.25
[fms.git]
/
src
/
bitmapvalidator.cpp
diff --git
a/src/bitmapvalidator.cpp
b/src/bitmapvalidator.cpp
index
771b707
..
12ba6de
100644
(file)
--- a/
src/bitmapvalidator.cpp
+++ b/
src/bitmapvalidator.cpp
@@
-6,11
+6,26
@@
#include <sstream>
\r
#include <cstdlib>
\r
\r
#include <sstream>
\r
#include <cstdlib>
\r
\r
+BitmapValidator::BitmapValidator():m_maxwidth(-1),m_maxheight(-1)
\r
+{
\r
+
\r
+}
\r
+
\r
+BitmapValidator::~BitmapValidator()
\r
+{
\r
+
\r
+}
\r
+
\r
const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)
\r
{
\r
bool validated=false;
\r
std::string tempname=Poco::TemporaryFile::tempName();
\r
\r
const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)
\r
{
\r
bool validated=false;
\r
std::string tempname=Poco::TemporaryFile::tempName();
\r
\r
+ if(data.size()==0)
\r
+ {
\r
+ return false;
\r
+ }
\r
+
\r
FILE *outfile=fopen(tempname.c_str(),"w+b");
\r
if(outfile)
\r
{
\r
FILE *outfile=fopen(tempname.c_str(),"w+b");
\r
if(outfile)
\r
{
\r
@@
-20,7
+35,15
@@
const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)
BMP temp;
\r
if(temp.ReadFromFile(tempname.c_str()))
\r
{
\r
BMP temp;
\r
if(temp.ReadFromFile(tempname.c_str()))
\r
{
\r
- validated=true;
\r
+ validated=true;
\r
+ if(m_maxwidth!=-1 && temp.TellWidth()>m_maxwidth)
\r
+ {
\r
+ validated=false;
\r
+ }
\r
+ if(m_maxheight!=-1 && temp.TellHeight()>m_maxheight)
\r
+ {
\r
+ validated=false;
\r
+ }
\r
}
\r
\r
unlink(tempname.c_str());
\r
}
\r
\r
unlink(tempname.c_str());
\r