File libraw-CVE-2017-14348.patch of Package libraw.8527
Index: LibRaw-0.17.1/internal/dcraw_common.cpp
===================================================================
--- LibRaw-0.17.1.orig/internal/dcraw_common.cpp 2017-09-15 18:28:13.330732870 +0200
+++ LibRaw-0.17.1/internal/dcraw_common.cpp 2017-09-15 18:28:27.758986666 +0200
@@ -5636,6 +5636,7 @@ void CLASS setCanonBodyFeatures (unsigne
void CLASS processCanonCameraInfo (unsigned id, uchar *CameraInfo, unsigned maxlen)
{
ushort iCanonLensID = 0, iCanonMaxFocal = 0, iCanonMinFocal = 0, iCanonLens = 0, iCanonCurFocal = 0, iCanonFocalType = 0;
+ if(maxlen<16) return; // too short, so broken
CameraInfo[0] = 0;
CameraInfo[1] = 0;
switch (id) {
@@ -6705,7 +6706,7 @@ void CLASS parse_makernote_0xc634(int ba
else if (tag == 0x000d) // camera info
{
- CanonCameraInfo = (uchar*)malloc(len);
+ CanonCameraInfo = (uchar*)malloc(MAX(16,len));
fread(CanonCameraInfo, len, 1, ifp);
lenCanonCameraInfo = len;
}
@@ -7475,7 +7476,7 @@ void CLASS parse_makernote (int base, in
else if (tag == 0x000d) // camera info
{
- CanonCameraInfo = (uchar*)malloc(len);
+ CanonCameraInfo = (uchar*)malloc(MAX(16,len));
fread(CanonCameraInfo, len, 1, ifp);
lenCanonCameraInfo = len;
}