Corrections to buffers size and check for data correctness
Bugfix 30D shot posted on forum
This commit is contained in:
@@ -53,7 +53,9 @@ class CAApertureInterpreter : public Interpreter {
|
||||
CAApertureInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", pow(2.0, t->toDouble()/64.0));
|
||||
double v = pow(2.0, t->toDouble()/64.0);
|
||||
if( v<0. || v> 1000.) return "undef";
|
||||
sprintf (buffer, "%.1f",v );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -74,7 +76,7 @@ public:
|
||||
int sec = t->toInt(0,SHORT);
|
||||
if( !sec ) return "OFF";
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1fs %s", sec/10., sec&0x4000?",Custom":"");
|
||||
sprintf (buffer, "%.1fs %s", sec/10., sec&0x4000?",Custom":"");
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -392,9 +394,11 @@ class CAFocalInterpreter : public Interpreter {
|
||||
public:
|
||||
virtual std::string toString (Tag* t) {
|
||||
Tag *unitTag = t->getParent()->getRoot()->findTag("FocalUnits");
|
||||
double unit = unitTag->toDouble();
|
||||
double v = unitTag?unitTag->toDouble():1.;
|
||||
v = (v>0. ? t->toDouble()/v : t->toDouble());
|
||||
if( v <0. || v>1000000.) return "undef";
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", (unit>0. ? t->toDouble()/unit : t->toDouble()));
|
||||
sprintf (buffer, "%.1f", v );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -741,8 +745,8 @@ public:
|
||||
virtual std::string toString (Tag* t) {
|
||||
int val = t->toInt();
|
||||
if( val <40 ) return "undef";
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.2fmm", val *25.4 / 1000);
|
||||
char buffer[1024];
|
||||
sprintf (buffer, "%.2fmm", val *25.4 / 1000);
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -751,8 +755,9 @@ CAFocalPlaneInterpreter caFocalPlaneInterpreter;
|
||||
class CAExposureTimeInterpreter : public Interpreter {
|
||||
public:
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.3f", pow (2, - t->toInt()/32.0) );
|
||||
char buffer[1024];
|
||||
double d = pow (2, - t->toInt()/32.0);
|
||||
sprintf (buffer, "%.3f", d);
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -760,8 +765,8 @@ CAExposureTimeInterpreter caExposureTimeInterpreter;
|
||||
|
||||
class CAEVInterpreter : public Interpreter {
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble()/32.0 );
|
||||
char buffer[1024];
|
||||
sprintf (buffer, "%.1f", t->toDouble()/32.0 );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -770,8 +775,8 @@ CAEVInterpreter caEVInterpreter;
|
||||
class CABaseISOInterpreter : public Interpreter {
|
||||
public:
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.0f", pow (2, t->toInt()/32.0 - 4) * 50 );
|
||||
char buffer[1024];
|
||||
sprintf (buffer, "%.0f", pow (2, t->toInt()/32.0 - 4) * 50 );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -865,7 +870,7 @@ public:
|
||||
int n= t->toInt();
|
||||
if( n==-1) return "undef";
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.f", n/32. );
|
||||
sprintf (buffer, "%.0f", n/32. );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -911,8 +916,8 @@ CAControModeInterpreter caControModeInterpreter;
|
||||
class CAFocusDistanceInterpreter : public Interpreter {
|
||||
public:
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.2f", t->toDouble()/100 );
|
||||
char buffer[1024];
|
||||
sprintf (buffer, "%.2f", t->toDouble()/100 );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -921,8 +926,8 @@ CAFocusDistanceInterpreter caFocusDistanceInterpreter;
|
||||
class CAMeasuredEVInterpreter : public Interpreter {
|
||||
public:
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble()/8 - 6 );
|
||||
char buffer[1024];
|
||||
sprintf (buffer, "%.1f", t->toDouble()/8 - 6 );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
@@ -233,7 +233,9 @@ public:
|
||||
PAFNumberInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble()/10);
|
||||
double v = t->toDouble()/10;
|
||||
if( v < 0. || v > 1000. ) return "undef";
|
||||
sprintf (buffer, "%.1f", v );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -709,7 +711,9 @@ class PAMaxApertureInterpreter: public Interpreter {
|
||||
a &= 0x7F;
|
||||
if(a>1){
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", pow(2.0, (a-1)/32.0));
|
||||
double v = pow(2.0, (a-1)/32.0);
|
||||
if( v < 0. || v > 1000. ) return "undef";
|
||||
sprintf (buffer, "%.1f", v );
|
||||
return buffer;
|
||||
}else
|
||||
return "n/a";
|
||||
@@ -725,7 +729,7 @@ public:
|
||||
int a = t->toInt(0,BYTE);
|
||||
int mina = a & 0x0F;
|
||||
int maxa = (a & 0xF0)>>4;
|
||||
sprintf (buffer, "%0.1f - %0.0f", pow(2.0, maxa/4.0), pow(2.0, (mina+10)/4.0));
|
||||
sprintf (buffer, "%.1f - %.0f", pow(2.0, maxa/4.0), pow(2.0, (mina+10)/4.0));
|
||||
return buffer;
|
||||
|
||||
}
|
||||
@@ -820,9 +824,9 @@ class PAExternalFlashGNInterpreter: public Interpreter {
|
||||
public:
|
||||
PAExternalFlashGNInterpreter(){}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
char buffer[1024];
|
||||
int b = t->toInt(0,BYTE) & 0x1F;
|
||||
sprintf (buffer, "%0.0f", pow(2.,b/16.+4) );
|
||||
sprintf (buffer, "%.0f", pow(2.,b/16.+4) );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
@@ -809,7 +809,7 @@ void Tag::toString (char* buffer, int ofs) {
|
||||
}
|
||||
}
|
||||
else if (type==ASCII) {
|
||||
sprintf (buffer, "%s", value+ofs);
|
||||
sprintf (buffer, "%.64s", value+ofs);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -828,8 +828,8 @@ void Tag::toString (char* buffer, int ofs) {
|
||||
case BYTE: sprintf (b, "%d", value[i+ofs]); break;
|
||||
case SSHORT: sprintf (b, "%d", toInt(2*i+ofs)); break;
|
||||
case SHORT: sprintf (b, "%u", toInt(2*i+ofs)); break;
|
||||
case SLONG: sprintf (b, "%ld", toInt(4*i+ofs)); break;
|
||||
case LONG: sprintf (b, "%lu", toInt(4*i+ofs)); break;
|
||||
case SLONG: sprintf (b, "%ld", (long)toInt(4*i+ofs)); break;
|
||||
case LONG: sprintf (b, "%lu", (unsigned long)toInt(4*i+ofs)); break;
|
||||
case SRATIONAL:
|
||||
case RATIONAL: sprintf (b, "%d/%d", (int)sget4 (value+8*i+ofs, getOrder()), (int)sget4 (value+8*i+ofs+4, getOrder())); break;
|
||||
case FLOAT: sprintf (b, "%g", toDouble(8*i+ofs)); break;
|
||||
@@ -841,7 +841,7 @@ void Tag::toString (char* buffer, int ofs) {
|
||||
|
||||
std::string Tag::nameToString (int i) {
|
||||
|
||||
static char buffer[1024];
|
||||
char buffer[1024];
|
||||
if (attrib)
|
||||
strcpy (buffer, attrib->name);
|
||||
else
|
||||
@@ -853,7 +853,7 @@ std::string Tag::nameToString (int i) {
|
||||
|
||||
std::string Tag::valueToString () {
|
||||
|
||||
static char buffer[1024];
|
||||
char buffer[1024];
|
||||
if (attrib && attrib->interpreter)
|
||||
return attrib->interpreter->toString (this);
|
||||
else {
|
||||
@@ -1107,7 +1107,7 @@ Tag* ExifManager::saveCIFFMNTag (FILE* f, TagDirectory* root, int len, const cha
|
||||
|
||||
void ExifManager::parseCIFF (FILE* f, int base, int length, TagDirectory* root) {
|
||||
|
||||
static char buffer[1024];
|
||||
char buffer[1024];
|
||||
Tag* t;
|
||||
|
||||
fseek (f, base+length-4, SEEK_SET);
|
||||
|
@@ -244,7 +244,9 @@ class FNumberInterpreter : public Interpreter {
|
||||
FNumberInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble());
|
||||
double v = t->toDouble();
|
||||
if( v < 0. || v > 1000. ) return "undef";
|
||||
sprintf (buffer, "%0.1f", v);
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -255,7 +257,9 @@ class ApertureInterpreter : public Interpreter {
|
||||
ApertureInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", pow(2.0, t->toDouble()/2.0));
|
||||
double v = pow(2.0, t->toDouble()/2.0);
|
||||
if( v < 0. || v > 1000. ) return "undef";
|
||||
sprintf (buffer, "%.1f", v );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -266,7 +270,9 @@ class ExposureBiasInterpreter : public Interpreter {
|
||||
ExposureBiasInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%+0.2f", t->toDouble());
|
||||
double v = t->toDouble();
|
||||
if( v < -1000. || v > 1000. ) return "undef";
|
||||
sprintf (buffer, "%+0.2f", v );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -276,12 +282,12 @@ class ShutterSpeedInterpreter : public Interpreter {
|
||||
public:
|
||||
ShutterSpeedInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
char buffer[1024];
|
||||
double d = pow (2.0, -t->toDouble());
|
||||
if (d > 0.0 && d < 0.9)
|
||||
sprintf (buffer, "1/%0.0f", 1.0 / d);
|
||||
sprintf (buffer, "1/%.0f", 1.0 / d);
|
||||
else
|
||||
sprintf (buffer, "%0.1f", d);
|
||||
sprintf (buffer, "%.1f", d);
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -291,12 +297,12 @@ class ExposureTimeInterpreter : public Interpreter {
|
||||
public:
|
||||
ExposureTimeInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
char buffer[1024];
|
||||
double d = t->toDouble();
|
||||
if (d > 0.0 && d < 0.9)
|
||||
sprintf (buffer, "1/%0.0f", 1.0 / d);
|
||||
sprintf (buffer, "1/%.0f", 1.0 / d);
|
||||
else
|
||||
sprintf (buffer, "%0.1f", d);
|
||||
sprintf (buffer, "%.1f", d);
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
@@ -307,7 +313,9 @@ class FocalLengthInterpreter : public Interpreter {
|
||||
FocalLengthInterpreter () {}
|
||||
virtual std::string toString (Tag* t) {
|
||||
char buffer[32];
|
||||
sprintf (buffer, "%0.1f", t->toDouble());
|
||||
double v = t->toDouble();
|
||||
if( v>1000000. || v<0 ) return "undef";
|
||||
sprintf (buffer, "%.1f", v );
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user