Fix a bug reported by cppcheck and an OOB access, kudos to Floessie
This commit is contained in:
parent
c8779c04f5
commit
b744eae46d
@ -121,61 +121,80 @@ void ImageData::extractInfo ()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
make = "";
|
memset(&time, 0, sizeof(time));
|
||||||
model = "";
|
|
||||||
serial = "";
|
|
||||||
orientation = "";
|
|
||||||
expcomp = 0;
|
|
||||||
shutter = 0;
|
|
||||||
aperture = 0;
|
|
||||||
focal_len = focal_len35mm = 0;
|
|
||||||
focus_dist = 0;
|
|
||||||
iso_speed = 0;
|
|
||||||
memset (&time, 0, sizeof(time));
|
|
||||||
timeStamp = 0;
|
timeStamp = 0;
|
||||||
|
iso_speed = 0;
|
||||||
|
aperture = 0.0;
|
||||||
|
focal_len = 0.0;
|
||||||
|
focal_len35mm = 0.0;
|
||||||
|
focus_dist = 0.0f;
|
||||||
|
shutter = 0.0;
|
||||||
|
expcomp = 0.0;
|
||||||
|
make.clear();
|
||||||
|
model.clear();
|
||||||
|
serial.clear();
|
||||||
|
orientation.clear();
|
||||||
|
lens.clear();
|
||||||
|
|
||||||
if (root->getTag ("Make")) {
|
if (root->getTag("Make")) {
|
||||||
make = root->getTag ("Make")->valueToString ();
|
make = root->getTag ("Make")->valueToString();
|
||||||
// same dcraw treatment
|
// Same dcraw treatment
|
||||||
static const char *corp[] = {
|
for (const auto& corp : {
|
||||||
"Canon", "NIKON", "EPSON", "KODAK", "Kodak", "OLYMPUS", "PENTAX", "RICOH",
|
"Canon",
|
||||||
"MINOLTA", "Minolta", "Konica", "CASIO", "Sinar", "Phase One",
|
"NIKON",
|
||||||
"SAMSUNG", "Mamiya", "MOTOROLA", "Leaf"
|
"EPSON",
|
||||||
};
|
"KODAK",
|
||||||
|
"Kodak",
|
||||||
for (size_t i = 0; i < (sizeof(corp) / sizeof(*corp)); i++)
|
"OLYMPUS",
|
||||||
if ( make.find( corp[i] ) != std::string::npos ) { /* Simplify company names */
|
"PENTAX",
|
||||||
make = corp[i];
|
"RICOH",
|
||||||
|
"MINOLTA",
|
||||||
|
"Minolta",
|
||||||
|
"Konica",
|
||||||
|
"CASIO",
|
||||||
|
"Sinar",
|
||||||
|
"Phase One",
|
||||||
|
"SAMSUNG",
|
||||||
|
"Mamiya",
|
||||||
|
"MOTOROLA",
|
||||||
|
"Leaf"
|
||||||
|
}) {
|
||||||
|
if (make.find(corp) != std::string::npos) { // Simplify company names
|
||||||
|
make = corp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
make.erase( make.find_last_not_of(' ') + 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root->getTag ("Model")) {
|
make.erase(make.find_last_not_of(' ') + 1);
|
||||||
model = root->getTag ("Model")->valueToString ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(model.size() == 0)) {
|
if (root->getTag("Model")) {
|
||||||
std::size_t i = 0;
|
model = root->getTag("Model")->valueToString();
|
||||||
|
|
||||||
if ( make.find("KODAK") != std::string::npos ) {
|
|
||||||
if( (i = model.find(" DIGITAL CAMERA")) != std::string::npos ||
|
|
||||||
(i = model.find(" Digital Camera")) != std::string::npos ||
|
|
||||||
(i = model.find("FILE VERSION")) ) {
|
|
||||||
model.resize( i );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model.erase( model.find_last_not_of(' ') + 1 );
|
if (!model.empty()) {
|
||||||
|
std::string::size_type i = 0;
|
||||||
|
|
||||||
//if( (i=model.find( make )) != std::string::npos )
|
if (
|
||||||
if( !strncasecmp (model.c_str(), make.c_str(), make.size()) )
|
make.find("KODAK") != std::string::npos
|
||||||
if( model.at( make.size() ) == ' ') {
|
&& (
|
||||||
|
(i = model.find(" DIGITAL CAMERA")) != std::string::npos
|
||||||
|
|| (i = model.find(" Digital Camera")) != std::string::npos
|
||||||
|
|| (i = model.find("FILE VERSION")) != std::string::npos
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
model.resize(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
model.erase(model.find_last_not_of(' ') + 1);
|
||||||
|
|
||||||
|
if (!strncasecmp(model.c_str(), make.c_str(), make.size())) {
|
||||||
|
if (model.size() >= make.size() && model[make.size()] == ' ') {
|
||||||
model.erase(0, make.size() + 1);
|
model.erase(0, make.size() + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( model.find( "Digital Camera ") != std::string::npos ) {
|
if (model.find( "Digital Camera ") != std::string::npos) {
|
||||||
model.erase(0, 15);
|
model.erase(0, 15);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user