Crash on reading floating point demosaiced DNG files, fixes #3600

This commit is contained in:
heckflosse 2017-01-09 14:31:49 +01:00
parent d54a6bcc8c
commit 1c3b3687f8
2 changed files with 23 additions and 16 deletions

View File

@ -9727,10 +9727,28 @@ static void copyFloatDataToInt(float * src, ushort * dst, size_t size, float max
}
void CLASS deflate_dng_load_raw() {
float_raw_image = new float[raw_width * raw_height];
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (size_t i = 0; i < raw_width * raw_height; ++i)
float_raw_image[i] = 0.0f;
if(tiff_samples != 1) {
fprintf(stderr, "deflate_dng_load_raw %s: demosaiced float dng files are not supported\n",ifname);
return;
}
struct tiff_ifd * ifd = &tiff_ifd[0];
while (ifd < &tiff_ifd[tiff_nifds] && ifd->offset != data_offset) ++ifd;
if (ifd == &tiff_ifd[tiff_nifds]) {
fprintf(stderr, "DNG Deflate: Raw image not found???\n");
fprintf(stderr, "deflate_dng_load_raw %s: Raw image not found???\n",ifname);
return;
}
if (ifd->sample_format != 3) { // no floating point data
fprintf(stderr, "deflate_dng_load_raw %s: Only float format is supported for deflate compressed dng files\n",ifname);
return;
}
@ -9742,16 +9760,6 @@ void CLASS deflate_dng_load_raw() {
default: predFactor = 0; break;
}
if (ifd->sample_format == 3) { // Floating point data
float_raw_image = new float[raw_width * raw_height];
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (size_t i = 0; i < raw_width * raw_height; ++i)
float_raw_image[i] = 0.0f;
}
// NOTE: This reader is based on the official DNG SDK from Adobe.
// It assumes tiles without subtiles, but the standard does not say that
// subtiles or strips couldn't be used.

View File

@ -1,8 +1,7 @@
Patch for vanilla dcraw. Please run this against any new dcraw version copied here.
Instructions for patching:
1) Download newest dcraw.c file, and copy to this folder.
2) Run 'patch -p0 < dcraw.patch' to patch the file. If there are any rejections, please fix them manually.
3) Move the patched dcraw.c to dcraw.cc
4) Re-copy the vanilla downloaded dcraw.c back to this folder, and update the patch: 'diff -u dcraw.c dcraw.cc > dcraw.patch'
1) Create the patch: 'diff -u dcraw.c dcraw.cc > dcraw.patch'
2) Download newest dcraw.c file, and copy to this folder.
3) Run 'patch -p0 < dcraw.patch' to patch the file. If there are any rejections, please fix them manually.
4) Move the patched dcraw.c to dcraw.cc