[Libreoffice-commits] .: 6 commits - bin/get-bugzilla-attachments-by-mimetype filter/CppunitTest_filter_pict_test.mk filter/Module_filter.mk filter/qa svtools/qa svtools/source
Caolán McNamara
caolan at kemper.freedesktop.org
Fri Jul 27 04:27:58 PDT 2012
bin/get-bugzilla-attachments-by-mimetype | 4
filter/CppunitTest_filter_pict_test.mk | 38 ++++++++
filter/Module_filter.mk | 1
filter/qa/cppunit/data/pict/fail/CVE-2012-0277-1.pct |binary
filter/qa/cppunit/data/pict/pass/ooo25876-2.pict |binary
filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-1.tiff |binary
filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-2.tiff |binary
filter/qa/cppunit/data/tiff/fail/CVE-2012-2027-1.tiff |binary
svtools/qa/cppunit/data/gif/pass/CVE-2012-0282-1.gif |binary
svtools/source/filter/filter.cxx | 83 ++++++++----------
svtools/source/filter/filter2.cxx | 23 +---
svtools/source/misc/imagemgr.cxx | 1
12 files changed, 91 insertions(+), 59 deletions(-)
New commits:
commit 2346f0d15822f9226cbb7e3cf2d63824bc26d817
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 27 11:47:43 2012 +0100
merge the two pict/pct detectors which disagree together
Change-Id: I63fc63884e3377f2707d99e7e85ab6761d37cd0a
diff --git a/svtools/source/filter/filter.cxx b/svtools/source/filter/filter.cxx
index aebb2d5..217f9a2 100644
--- a/svtools/source/filter/filter.cxx
+++ b/svtools/source/filter/filter.cxx
@@ -198,6 +198,44 @@ inline String ImpGetExtension( const String &rPath )
return aExt;
}
+bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen)
+{
+ sal_uInt8 sBuf[3];
+ // store number format
+ sal_uInt16 oldNumberFormat = rStream.GetNumberFormatInt();
+ sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes
+ for ( nOffset = 0; ( nOffset <= 512 ) && ( ( nStreamPos + nOffset + 14 ) <= nStreamLen ); nOffset += 512 )
+ {
+ short y1,x1,y2,x2;
+ sal_Bool bdBoxOk = sal_True;
+
+ rStream.Seek( nStreamPos + nOffset);
+ // size of the pict in version 1 pict ( 2bytes) : ignored
+ rStream.SeekRel(2);
+ // bounding box (bytes 2 -> 9)
+ rStream.SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
+ rStream >> y1 >> x1 >> y2 >> x2;
+ rStream.SetNumberFormatInt(oldNumberFormat); // reset format
+
+ if (x1 > x2 || y1 > y2 || // bad bdbox
+ (x1 == x2 && y1 == y2) || // 1 pixel picture
+ x2-x1 > 2048 || y2-y1 > 2048 ) // picture anormaly big
+ bdBoxOk = sal_False;
+
+ // read version op
+ rStream.Read( sBuf,3 );
+ // see http://developer.apple.com/legacy/mac/library/documentation/mac/pdf/Imaging_With_QuickDraw/Appendix_A.pdf
+ // normal version 2 - page A23 and A24
+ if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && sBuf[ 2 ] == 0x02)
+ return true;
+ // normal version 1 - page A25
+ else if (sBuf[ 0 ] == 0x11 && sBuf[ 1 ] == 0x01 && bdBoxOk)
+ return true;
+ }
+ return false;
+}
+
+
/*************************************************************************
|*
|* ImpPeekGraphicFormat()
@@ -533,49 +571,10 @@ static sal_Bool ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtensio
if( !bTest || ( rFormatExtension.CompareToAscii( "PCT", 3 ) == COMPARE_EQUAL ) )
{
bSomethingTested = sal_True;
- sal_uInt8 sBuf[3];
- // store number format
- sal_uInt16 oldNumberFormat = rStream.GetNumberFormatInt();
- sal_uInt32 nOffset; // in ms documents the pict format is used without the first 512 bytes
- for ( nOffset = 0; ( nOffset <= 512 ) && ( ( nStreamPos + nOffset + 14 ) <= nStreamLen ); nOffset += 512 )
+ if (isPCT(rStream, nStreamPos, nStreamLen))
{
- short y1,x1,y2,x2;
- sal_Bool bdBoxOk = sal_True;
-
- rStream.Seek( nStreamPos + nOffset);
- // size of the pict in version 1 pict ( 2bytes) : ignored
- rStream.SeekRel(2);
- // bounding box (bytes 2 -> 9)
- rStream.SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
- rStream >> y1 >> x1 >> y2 >> x2;
- rStream.SetNumberFormatInt(oldNumberFormat); // reset format
-
- if (x1 > x2 || y1 > y2 || // bad bdbox
- (x1 == x2 && y1 == y2) || // 1 pixel picture
- x2-x1 > 2048 || y2-y1 > 2048 ) // picture anormaly big
- bdBoxOk = sal_False;
-
- // read version op
- rStream.Read( sBuf,3 );
- // see http://developer.apple.com/legacy/mac/library/documentation/mac/pdf/Imaging_With_QuickDraw/Appendix_A.pdf
- // normal version 2 - page A23 and A24
- if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && sBuf[ 2 ] == 0x02)
- {
- rFormatExtension = rtl::OUString("PCT");
- return sal_True;
- }
- // normal version 1 - page A25
- else if (sBuf[ 0 ] == 0x11 && sBuf[ 1 ] == 0x01 && bdBoxOk) {
- rFormatExtension = rtl::OUString("PCT");
- return sal_True;
- }
- // previous code kept in order to do not break any compatibility
- // probably eroneous
- else if ( sBuf[ 0 ] == 0x00 && sBuf[ 1 ] == 0x11 && sBuf[ 2 ] == 0x01 && bdBoxOk)
- {
- rFormatExtension = rtl::OUString("PCT");
- return sal_True;
- }
+ rFormatExtension = rtl::OUString("PCT");
+ return sal_True;
}
}
diff --git a/svtools/source/filter/filter2.cxx b/svtools/source/filter/filter2.cxx
index d229dcb..54649b2 100644
--- a/svtools/source/filter/filter2.cxx
+++ b/svtools/source/filter/filter2.cxx
@@ -1104,6 +1104,8 @@ sal_Bool GraphicDescriptor::ImpDetectMET( SvStream&, sal_Bool )
|*
\************************************************************************/
+extern bool isPCT(SvStream& rStream, sal_uLong nStreamPos, sal_uLong nStreamLen);
+
sal_Bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, sal_Bool )
{
sal_Bool bRet = aPathExt.CompareToAscii( "pct", 3 ) == COMPARE_EQUAL;
@@ -1111,23 +1113,14 @@ sal_Bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, sal_Bool )
nFormat = GFF_PCT;
else
{
- sal_Int32 nStmPos = rStm.Tell();
-
- sal_uInt8 sBuf[4];
-
- rStm.SeekRel( 522 );
- rStm.Read( sBuf, 3 );
-
- if( !rStm.GetError() )
+ sal_Size nStreamPos = rStm.Tell();
+ sal_Size nStreamLen = rStm.remainingSize();
+ if (isPCT(rStm, nStreamPos, nStreamLen))
{
- if ( ( sBuf[0] == 0x00 ) && ( sBuf[1] == 0x11 ) &&
- ( ( sBuf[2] == 0x01 ) || ( sBuf[2] == 0x02 ) ) )
- {
- bRet = sal_True;
- nFormat = GFF_PCT;
- }
+ bRet = sal_True;
+ nFormat = GFF_PCT;
}
- rStm.Seek( nStmPos );
+ rStm.Seek(nStreamPos);
}
return bRet;
diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
index 044275e..3a0943f 100644
--- a/svtools/source/misc/imagemgr.cxx
+++ b/svtools/source/misc/imagemgr.cxx
@@ -121,6 +121,7 @@ static SvtExtensionResIdMapping_Impl const ExtensionMap_Impl[] =
{ "pas", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
{ "pcd", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCD },
{ "pct", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT },
+ { "pict", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCT },
{ "pcx", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PCX },
{ "pl", sal_True, STR_DESCRIPTION_SOURCEFILE, 0 },
{ "png", sal_True, STR_DESCRIPTION_GRAPHIC_DOC, IMG_PNG },
commit 56283f6e69ea80411986a44b49b9af1f58bb0254
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 27 10:37:12 2012 +0100
add some more tiff tests
Change-Id: Iedc80fba8d25c7a8bc67d835b202fb9be61cb783
diff --git a/filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-1.tiff b/filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-1.tiff
new file mode 100644
index 0000000..ea6dd77
Binary files /dev/null and b/filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-1.tiff differ
diff --git a/filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-2.tiff b/filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-2.tiff
new file mode 100644
index 0000000..a66476b
Binary files /dev/null and b/filter/qa/cppunit/data/tiff/fail/CVE-2012-0276-2.tiff differ
diff --git a/filter/qa/cppunit/data/tiff/fail/CVE-2012-2027-1.tiff b/filter/qa/cppunit/data/tiff/fail/CVE-2012-2027-1.tiff
new file mode 100644
index 0000000..ea6dd77
Binary files /dev/null and b/filter/qa/cppunit/data/tiff/fail/CVE-2012-2027-1.tiff differ
commit 7abe82d525caba1d7ad607d730bc75a6d7f05174
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 27 10:36:47 2012 +0100
add pict regression test
Change-Id: I6765bd2de27971c441a7d3f8879e4fd9bc3112cf
diff --git a/filter/CppunitTest_filter_pict_test.mk b/filter/CppunitTest_filter_pict_test.mk
new file mode 100644
index 0000000..ce9eeb6
--- /dev/null
+++ b/filter/CppunitTest_filter_pict_test.mk
@@ -0,0 +1,38 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+$(eval $(call gb_CppunitTest_CppunitTest,filter_pict_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,filter_pict_test, \
+ filter/qa/cppunit/filters-pict-test \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,filter_pict_test, \
+ ipt \
+ sal \
+ test \
+ tl \
+ unotest \
+ vcl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,filter_pict_test,\
+ udkapi \
+ offapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,filter_pict_test))
+
+$(eval $(call gb_CppunitTest_use_components,filter_pict_test,\
+ configmgr/source/configmgr \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,filter_pict_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index c3554f9..d719a38 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_Module_add_targets,filter,\
endif
$(eval $(call gb_Module_add_check_targets,filter,\
+ CppunitTest_filter_pict_test \
CppunitTest_filter_tga_test \
CppunitTest_filter_tiff_test \
))
diff --git a/filter/qa/cppunit/data/pict/fail/.gitignore b/filter/qa/cppunit/data/pict/fail/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/filter/qa/cppunit/data/pict/fail/CVE-2012-0277-1.pct b/filter/qa/cppunit/data/pict/fail/CVE-2012-0277-1.pct
new file mode 100644
index 0000000..5683a55
Binary files /dev/null and b/filter/qa/cppunit/data/pict/fail/CVE-2012-0277-1.pct differ
diff --git a/filter/qa/cppunit/data/pict/indeterminate/.gitignore b/filter/qa/cppunit/data/pict/indeterminate/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/filter/qa/cppunit/data/pict/pass/.gitignore b/filter/qa/cppunit/data/pict/pass/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/filter/qa/cppunit/data/pict/pass/ooo25876-2.pict b/filter/qa/cppunit/data/pict/pass/ooo25876-2.pict
new file mode 100644
index 0000000..9807e36
Binary files /dev/null and b/filter/qa/cppunit/data/pict/pass/ooo25876-2.pict differ
commit 0f05c39c4d87ed1b44f019b332c6241b749b88e1
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 27 10:35:03 2012 +0100
add regression test for gif that nobbled XnView
Change-Id: Ib5d456fa8e10a680ab79dd60bca99b37d0859078
diff --git a/svtools/qa/cppunit/data/gif/pass/CVE-2012-0282-1.gif b/svtools/qa/cppunit/data/gif/pass/CVE-2012-0282-1.gif
new file mode 100644
index 0000000..cf4f30c
Binary files /dev/null and b/svtools/qa/cppunit/data/gif/pass/CVE-2012-0282-1.gif differ
commit ff7c116621189256e118fa0ba3c9c51bd99f081d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 27 09:42:43 2012 +0100
want to search for some sample pcts
Change-Id: I1e3c8e0994d17c6d5465fe63ab73f927e90c4991
diff --git a/bin/get-bugzilla-attachments-by-mimetype b/bin/get-bugzilla-attachments-by-mimetype
index 0ddec68..6d5177b 100755
--- a/bin/get-bugzilla-attachments-by-mimetype
+++ b/bin/get-bugzilla-attachments-by-mimetype
@@ -320,6 +320,7 @@ mimetypes = {
'image/x-sgf': 'sgf',
'image/x-svm': 'svm',
'image/x-wmf': 'wmf',
+ 'image/x-pict': 'pict',
}
# disabled for now, this would download gigs of pngs/jpegs...
@@ -332,7 +333,6 @@ common_noncore_mimetypes = [
('image/x-met', 'met'),
('image/x-portable-bitmap', 'pbm'),
('image/x-photo-cd', 'pcd'),
- ('image/x-pict', 'pict'),
('image/x-pcx', 'pcx'),
('image/x-portable-graymap', 'pgm'),
('image/x-portable-pixmap', 'ppm'),
commit 96215af8ad5a409680f5d243886b95ed9478850a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jul 27 09:42:08 2012 +0100
redhat bugzilla changed a bit
Change-Id: I95f0a96ac52ae929e20096d135207f8a0c040ca5
diff --git a/bin/get-bugzilla-attachments-by-mimetype b/bin/get-bugzilla-attachments-by-mimetype
index c98edd7..0ddec68 100755
--- a/bin/get-bugzilla-attachments-by-mimetype
+++ b/bin/get-bugzilla-attachments-by-mimetype
@@ -141,7 +141,7 @@ def get_through_rpc_query(rpcurl, showurl, mimetype, prefix, suffix):
bugs = result['bugs']
print len(bugs), 'bugs to process'
for bug in bugs:
- url = showurl + str(bug['bug_id'])
+ url = showurl + str(bug['id'])
get_from_bug_url_via_xml(url, mimetype, prefix, suffix)
except xmlrpclib.Fault, err:
print "A fault occurred"
More information about the Libreoffice-commits
mailing list