From b71059533585cbcc8ddf9b5732803e7a8a401449 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 10 Aug 2016 22:59:48 +0200 Subject: [PATCH] Adust buffers to fix potential buffer overruns --- rtexif/canonattribs.cc | 10 +++++----- rtexif/pentaxattribs.cc | 8 ++++---- rtexif/sonyminoltaattribs.cc | 14 +++++++------- rtexif/stdattribs.cc | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rtexif/canonattribs.cc b/rtexif/canonattribs.cc index a4f4ab8b8..e013b2534 100644 --- a/rtexif/canonattribs.cc +++ b/rtexif/canonattribs.cc @@ -1050,7 +1050,7 @@ public: return "undef"; } - char buffer[1024]; + char buffer[32]; sprintf (buffer, "%.2fmm", val * 25.4 / 1000); return buffer; } @@ -1062,7 +1062,7 @@ class CAExposureTimeInterpreter : public Interpreter public: virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; double d = pow (2, - t->toInt() / 32.0); sprintf (buffer, "%.3f", d); return buffer; @@ -1074,7 +1074,7 @@ class CAEVInterpreter : public Interpreter { virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; sprintf (buffer, "%.1f", t->toDouble() / 32.0 ); return buffer; } @@ -1281,7 +1281,7 @@ class CAFocusDistanceInterpreter : public Interpreter public: virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; sprintf (buffer, "%.2f", t->toDouble() / 100 ); return buffer; } @@ -1293,7 +1293,7 @@ class CAMeasuredEVInterpreter : public Interpreter public: virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; sprintf (buffer, "%.1f", t->toDouble() / 8 - 6 ); return buffer; } diff --git a/rtexif/pentaxattribs.cc b/rtexif/pentaxattribs.cc index 91a508244..f88e650ec 100644 --- a/rtexif/pentaxattribs.cc +++ b/rtexif/pentaxattribs.cc @@ -1320,7 +1320,7 @@ public: a = t->toInt(0, SBYTE) / 6; // int8u[2] } - char buffer[10]; + char buffer[32]; sprintf (buffer, "%d", a ); return buffer; } @@ -1348,7 +1348,7 @@ public: double a = double(t->toInt(0, LONG)); if(a > 1.) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%.2f", a / 100. ); return buffer; } else { @@ -1378,7 +1378,7 @@ public: float b = float(10 * int(a >> 2)) * pow(4.f, float(int(a & 0x03) - 2)); if(b > 1.f) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%.2f", b ); return buffer; } else { @@ -1680,7 +1680,7 @@ public: PAExternalFlashGNInterpreter() {} virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; int b = t->toInt(0, BYTE) & 0x1F; sprintf (buffer, "%.0f", pow(2., b / 16. + 4) ); return buffer; diff --git a/rtexif/sonyminoltaattribs.cc b/rtexif/sonyminoltaattribs.cc index a0d280df1..7f4e1bb53 100644 --- a/rtexif/sonyminoltaattribs.cc +++ b/rtexif/sonyminoltaattribs.cc @@ -1955,7 +1955,7 @@ public: double a = t->toDouble(); if(a > 0) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%.4f", a); return buffer; } else { @@ -2015,7 +2015,7 @@ public: double a = double(t->toDouble()); if(a) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%.1f", a / 100. ); return buffer; } else { @@ -2075,7 +2075,7 @@ public: int a = t->toInt(); if(a) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%d", a ); return buffer; } else { @@ -2114,7 +2114,7 @@ public: virtual std::string toString (Tag* t) { double a = t->toDouble(); - char buffer[10]; + char buffer[32]; sprintf (buffer, "%.2f", a ); return buffer; } @@ -2134,7 +2134,7 @@ public: SAAFMicroAdjValueInterpreter() {} virtual std::string toString (Tag* t) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%d", t->getValue()[0] - 20); return buffer; } @@ -2173,7 +2173,7 @@ public: SAAFMicroAdjRegisteredLensesInterpreter() {} virtual std::string toString (Tag* t) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%d", t->getValue()[0] & 0x7f); return buffer; } @@ -2229,7 +2229,7 @@ public: SAColorTemperatureSettingInterpreter () {} virtual std::string toString (Tag* t) { - char buffer[10]; + char buffer[32]; sprintf (buffer, "%d", t->toInt()); return buffer; } diff --git a/rtexif/stdattribs.cc b/rtexif/stdattribs.cc index 0d7c38ff9..98594e64c 100644 --- a/rtexif/stdattribs.cc +++ b/rtexif/stdattribs.cc @@ -386,7 +386,7 @@ public: ShutterSpeedInterpreter () {} virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; double d = pow (2.0, -t->toDouble()); if (d > 0.0 && d < 0.9) { @@ -406,7 +406,7 @@ public: ExposureTimeInterpreter () {} virtual std::string toString (Tag* t) { - char buffer[1024]; + char buffer[32]; double d = t->toDouble(); if (d > 0.0 && d < 0.9) {