From kde-i18n-doc Sun Oct 23 14:25:22 2016 From: Boudewijn Rempt Date: Sun, 23 Oct 2016 14:25:22 +0000 To: kde-i18n-doc Subject: [krita] /: BUG:371523 Do not crash on opening Gimp 2.9 files Message-Id: X-MARC-Message: https://marc.info/?l=kde-i18n-doc&m=147723274309844 Git commit adf8f6ee59820f5147a60af82bc3ff7e2f873153 by Boudewijn Rempt. Committed on 23/10/2016 at 14:25. Pushed by rempt into branch 'master'. BUG:371523 Do not crash on opening Gimp 2.9 files Krita cannot load Gimp 2.9 files (and never will be, probably, because xcf-tools isn't maintained anymore and the file format is un(der)documented). But we shouldn't crash and burn trying to load them anyway. This adds two new strings for translation, I'm afraid :-( CCMAIL:kde-i18n-doc@kde.org M +5 -0 libs/ui/KisImportExportFilter.cpp M +1 -0 libs/ui/KisImportExportFilter.h M +9 -11 plugins/impex/xcf/3rdparty/xcftools/xcf-general.c M +6 -0 plugins/impex/xcf/kis_xcf_import.cpp http://commits.kde.org/krita/adf8f6ee59820f5147a60af82bc3ff7e2f873153 diff --git a/libs/ui/KisImportExportFilter.cpp b/libs/ui/KisImportExportFil= ter.cpp index 5fd237a..c3dbcbd 100644 --- a/libs/ui/KisImportExportFilter.cpp +++ b/libs/ui/KisImportExportFilter.cpp @@ -153,11 +153,16 @@ QString KisImportExportFilter::conversionStatusString= (ConversionStatus status) = msg =3D i18n("Unknown file type"); break; = + case UnsupportedVersion: + + msg =3D i18n("Unsupported file version"); break; + case UserCancelled: = // intentionally we do not prompt the error message here break; = + default: msg =3D i18n("Unknown error"); break; } return msg; diff --git a/libs/ui/KisImportExportFilter.h b/libs/ui/KisImportExportFilte= r.h index c5bc6e6..3ffdb39 100644 --- a/libs/ui/KisImportExportFilter.h +++ b/libs/ui/KisImportExportFilter.h @@ -93,6 +93,7 @@ public: DownloadFailed, FilterCreationError, ProgressCancelled, + UnsupportedVersion, JustInCaseSomeBrokenCompilerUsesLessThanAByte = =3D 255 }; = diff --git a/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c b/plugins/im= pex/xcf/3rdparty/xcftools/xcf-general.c index b23c260..3716917 100644 --- a/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c +++ b/plugins/impex/xcf/3rdparty/xcftools/xcf-general.c @@ -2,7 +2,7 @@ * * This file was written by Henning Makholm * It is hereby in the public domain. - * = + * * In jurisdictions that do not recognise grants of copyright to the * public domain: I, the author and (presumably, in those jurisdictions) * copyright holder, hereby permit anyone to distribute and use this code, @@ -92,7 +92,7 @@ xcfString(uint32_t ptr,uint32_t *after) uint32_t length ; unsigned i ; ICONV_CONST char *utf8master ; - = + xcfCheckspace(ptr,4,"(string length)"); length =3D xcfL(ptr) ; ptr +=3D 4 ; @@ -197,7 +197,7 @@ getBasicXcfInfo(void) uint32_t ptr, data, layerfile ; PropType type ; int i, j ; - = + xcfCheckspace(0,14+7*4,"(very short)"); if( strcmp((char*)xcf_file,"gimp xcf file") =3D=3D 0 ) XCF.version =3D 0 ; @@ -207,15 +207,13 @@ getBasicXcfInfo(void) else FatalBadXCF(_("Not an XCF file at all (magic not recognized)")); = - if( XCF.version < 0 || XCF.version > 3 ) { - fprintf(stderr, - _("Warning: XCF version %d not supported (trying anyway...)\n"= ), - XCF.version); + if (XCF.version < 0 || XCF.version > 3) { + return; } - = + XCF.compression =3D COMPRESS_NONE ; XCF.colormapptr =3D 0 ; - = + ptr =3D 14 ; XCF.width =3D xcfL(ptr); ptr +=3D 4 ; XCF.height =3D xcfL(ptr); ptr +=3D 4 ; @@ -283,9 +281,9 @@ getBasicXcfInfo(void) L->pathLength =3D (ptr - data - 2) / 4 ; = if ( L->pathLength !=3D 0 ) { - = + L->path =3D xcfmalloc( L->pathLength * sizeof(unsigned) ) ; - = + for ( j =3D 0; j!=3DL->pathLength; j++ ) *(L->path + j) =3D (unsigned)xcfL(data + 4 * j); } diff --git a/plugins/impex/xcf/kis_xcf_import.cpp b/plugins/impex/xcf/kis_x= cf_import.cpp index d926632..939003b 100644 --- a/plugins/impex/xcf/kis_xcf_import.cpp +++ b/plugins/impex/xcf/kis_xcf_import.cpp @@ -196,6 +196,12 @@ KisImportExportFilter::ConversionStatus KisXCFImport::= loadFromDevice(QIODevice* = // Decode the data getBasicXcfInfo() ; + + if (XCF.version < 0 || XCF.version > 3) { + doc->setErrorMessage(i18n("This XCF file is too new; Krita cannot = support XCF files written by GIMP 2.9 or newer.")); + return KisImportExportFilter::UnsupportedVersion; + } + initColormap(); = dbgFile << XCF.version << "width =3D " << XCF.width << "height =3D " <= < XCF.height << "layers =3D " << XCF.numLayers;