tag 569788 + patch thanks I think the attached patch should fix this issue. It's working for me: I'm attaching the test case I'm using (it's a modification on an example provided within the package).
Using the package in unstable: > [12:30] giova...@edelstein:~/packages/openraw/test$ gcc `pkg-config --cflags > --libs libopenraw-1.0` -g -o thumb thumbc.c > [12:30] giova...@edelstein:~/packages/openraw/test$ ./thumb ../p1080081.orf > registering type 1 > registering type 3 > registering type 5 > registering type 7 > registering type 6 > registering type 8 > registering type 2 > registering type 9 > registering type 4 > factory size 9 > getRawData() > _locateDirs() > Identified ORF file > push offset =0x8 > numEntries =21 shifting 254bytes > # dir found = 1 > IFDDir::load() m_offset =8 > counting tiles > RAW Compression is 1 > _getCfaPattern > IFDDir::load() m_offset =8 > Exif IFD offset (uncorrected) = 266 > Exif IFD offset = 266 > IFDDir::load() m_offset =266 > _getCfaPattern > patter is = 0, 1, 1, 2 > allocate s=9619532 data =0 > data =0x7fd5e5b76010 > allocate s=31248000 data =0 > data =0x7fd5e3da9010 > Segmentation fault Using the patched version: > [12:36] giova...@edelstein:~/packages/openraw/test$ gcc `pkg-config --cflags > --libs libopenraw-1.0` -g -o thumb thumbc.c > [12:37] giova...@edelstein:~/packages/openraw/test$ ./thumb ../p1080081.orf > registering type 1 > registering type 3 > registering type 5 > registering type 7 > registering type 6 > registering type 8 > registering type 2 > registering type 9 > registering type 4 > factory size 9 > options are 0 > getRawData() > _locateDirs() > Identified ORF file > push offset =0x8 > numEntries =21 shifting 254bytes > # dir found = 1 > IFDDir::load() m_offset =8 > counting tiles > RAW Compression is 1 > _getCfaPattern > IFDDir::load() m_offset =8 > Exif IFD offset (uncorrected) = 266 > Exif IFD offset = 266 > IFDDir::load() m_offset =266 > _getCfaPattern > patter is = 0, 1, 1, 2 > allocate s=9619532 data =0 > data =0x7fbd8adcb010 > wrong data type > error 7 The program still fails (my understanding is that it's not able to read the compressed ORF file), but at least it fails gracefully instead of segfaulting. I'm not NMU-ing this patch because I'll be VAC and not reachable starting Thursday or Friday. Ciao, Giovanni. -- Giovanni Mascellani <[email protected]> Pisa, Italy Web: http://poisson.phc.unipi.it/~mascellani Jabber: [email protected] / [email protected]
From ca456c292e1c311d8fb0eed12a440813facb3f20 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani <[email protected]> Date: Mon, 9 Aug 2010 12:28:56 +0200 Subject: [PATCH] Fix segmentation fault for some compressed ORF files --- README | 4 ++-- debian/changelog | 7 +++++++ lib/orffile.cpp | 33 +++++++++++++++++++++++++++++---- lib/rawfile.cpp | 7 ++++++- testsuite/testsuite.xml | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 7 deletions(-) diff --git a/README b/README index b4716ee..620e556 100644 --- a/README +++ b/README @@ -114,9 +114,9 @@ Olympus ORF Y Y N Y Y Y E-10 B B T E-3 T T T E-300 T T B T T T - E-330 T T T + E-330 T T N T E-400 T B T T - E-410 B T T T + E-410 B T N T T E-500 T T T T E-510 B T T T SP-350 diff --git a/debian/changelog b/debian/changelog index 59f5774..06abd44 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libopenraw (0.0.8-1.1) unstable; urgency=low + + * Non-maintainer upload. + * Fix segmentation fault with some ORF files (closes: #569788). + + -- Giovanni Mascellani <[email protected]> Mon, 09 Aug 2010 12:32:02 +0200 + libopenraw (0.0.8-1) unstable; urgency=low * New upstream version diff --git a/lib/orffile.cpp b/lib/orffile.cpp index c9f0181..28980f4 100644 --- a/lib/orffile.cpp +++ b/lib/orffile.cpp @@ -1,7 +1,7 @@ /* * libopenraw - orffile.cpp * - * Copyright (C) 2006, 2008 Hubert Figuiere + * Copyright (C) 2006, 2008, 2010 Hubert Figuiere * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -77,7 +77,7 @@ namespace OpenRaw { IFDDir::Ref ORFFile::_locateCfaIfd() { - // in PEF the CFA IFD is the main IFD + // in ORF the CFA IFD is the main IFD if(!m_mainIfd) { m_mainIfd = _locateMainIfd(); } @@ -92,12 +92,37 @@ namespace OpenRaw { - ::or_error ORFFile::_getRawData(RawData & data, uint32_t /*options*/) + ::or_error ORFFile::_getRawData(RawData & data, uint32_t options) { + ::or_error err; if(!m_cfaIfd) { m_cfaIfd = _locateCfaIfd(); } - return _getRawDataFromDir(data, m_cfaIfd); + err = _getRawDataFromDir(data, m_cfaIfd); + if(err == OR_ERROR_NONE) { + // ORF files seems to be marked as uncompressed even if they are. + uint32_t x = data.x(); + uint32_t y = data.y(); + uint16_t compression = 0; + if(data.size() < x * y * 2) { + compression = 65535; + data.setCompression(65535); + data.setDataType(OR_DATA_TYPE_COMPRESSED_CFA); + } + else { + compression = data.compression(); + } + switch(compression) { + case 65535: + if((options & OR_OPTIONS_DONT_DECOMPRESS) == 0) { + // TODO decompress + } + break; + default: + break; + } + } + return err; } } diff --git a/lib/rawfile.cpp b/lib/rawfile.cpp index 6b0821b..c1c11cb 100644 --- a/lib/rawfile.cpp +++ b/lib/rawfile.cpp @@ -1,8 +1,8 @@ /* * libopenraw - rawfile.cpp * - * Copyright (C) 2006-2008 Hubert Figuiere * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2006-2008, 2010 Hubert Figuiere * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -379,8 +379,13 @@ const std::vector<uint32_t> & RawFile::listThumbnailSizes(void) ::or_error RawFile::getRenderedImage(BitmapData & bitmapdata, uint32_t options) { RawData rawdata; + Trace(DEBUG1) << "options are " << options << "\n"; ::or_error ret = getRawData(rawdata, options); if(ret == OR_ERROR_NONE) { + if(rawdata.dataType() != OR_DATA_TYPE_CFA) { + Trace(DEBUG1) << "wrong data type\n"; + return OR_ERROR_INVALID_FORMAT; + } uint32_t x,y; or_cfa_pattern pattern; uint16_t *src; diff --git a/testsuite/testsuite.xml b/testsuite/testsuite.xml index d92af4c..6231760 100644 --- a/testsuite/testsuite.xml +++ b/testsuite/testsuite.xml @@ -346,6 +346,42 @@ </results> </test> <test> + <name>ORF-test E330</name> + <file>/home/hub/samples/300mm_f5.6.ORF</file> + <source>http://raw.fotosite.pl/download-Olympus_E-330_Sigma_135-400_f4.5-5.6/300mm_f5.6.ORF</source> + <results> + <rawType>ORF</rawType> + <rawTypeId>458757</rawTypeId> + <thumbNum>1</thumbNum> + <thumbSizes>160</thumbSizes> + <thumbFormats>JPEG</thumbFormats> + <thumbDataSizes>11074</thumbDataSizes> + <rawDataType>COMP_CFA</rawDataType> + <rawDataSize>12857600</rawDataSize> + <rawDataDimensions>3280 2450</rawDataDimensions> + <rawCfaPattern>RGGB</rawCfaPattern> + <rawMinValue>0</rawMinValue> + <rawMaxValue>65535</rawMaxValue> + <metaOrientation>1</metaOrientation> + </results> + </test> + <test> + <name>ORF-test E-410</name> + <file>/home/hub/samples/p1013308.orf</file> + <results> + <rawType>ORF</rawType> + <rawTypeId>458759</rawTypeId> + <thumbNum>0</thumbNum> + <rawDataType>COMP_CFA</rawDataType> + <rawDataSize>8131436</rawDataSize> + <rawDataDimensions>3720 2800</rawDataDimensions> + <rawCfaPattern>RGGB</rawCfaPattern> + <rawMinValue>0</rawMinValue> + <rawMaxValue>65535</rawMaxValue> + <metaOrientation>1</metaOrientation> + </results> + </test> + <test> <name>MRW-test Dimage5</name> <file>/home/hub/samples/mrw/Dimage5/dimage5.mrw</file> <source>http://libopenraw.freedesktop.org/samples/mrw/dimage5.mrw</source> -- 1.7.1
/*
* libopenraw - thumbc.c
*
* Copyright (C) 2006,2008 Hubert Figuiere
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <libopenraw/libopenraw.h>
int
main(int argc, char **argv)
{
char *filename;
int thumb_size = 160;
int opt;
ORThumbnailRef thumbnail = NULL;
while ((opt = getopt(argc, argv, "s:")) != -1) {
switch(opt) {
case 's':
thumb_size = atoi(optarg);
break;
default:
break;
}
}
if(optind >= argc) {
fprintf(stderr, "Missing filename\n");
return 1;
}
filename = argv[optind];
(void)argc;
or_debug_set_level(DEBUG2);
if(filename && *filename)
{
void *thumbnailData;
or_data_type thumbnailFormat;
size_t dataSize;
size_t writtenSize;
FILE *output;
uint32_t x, y;
or_error err;
ORRawFileRef rafRef = or_rawfile_new(filename, OR_RAWFILE_TYPE_UNKNOWN);
ORBitmapDataRef bitmapRef = or_bitmapdata_new();
err = or_rawfile_get_rendered_image(rafRef, bitmapRef, 0);
if (err == OR_ERROR_NONE) {
printf("ok\n");
}
else {
printf("error %d\n", err);
}
}
else {
printf("No input file name\n");
}
return 0;
}
signature.asc
Description: OpenPGP digital signature

