[qt] Fix QTgaHandler::canRead() not obeying image plugin specs

Than Ngo than at fedoraproject.org
Fri Mar 30 20:05:46 UTC 2012


commit 215aa5fd0890d87cff25e872a94d1252aa304780
Author: Than Ngo <than at redhat.com>
Date:   Fri Mar 30 22:05:31 2012 +0200

    Fix QTgaHandler::canRead() not obeying image plugin specs

 ...verywhere-opensource-src-4.8.1-qtgahandle.patch |   53 ++++++++++++++++++++
 qt.spec                                            |    8 +++-
 2 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/qt-everywhere-opensource-src-4.8.1-qtgahandle.patch b/qt-everywhere-opensource-src-4.8.1-qtgahandle.patch
new file mode 100644
index 0000000..64ffef3
--- /dev/null
+++ b/qt-everywhere-opensource-src-4.8.1-qtgahandle.patch
@@ -0,0 +1,53 @@
+diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp
+--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me	2012-03-30 21:54:59.921331145 +0200
++++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp	2012-03-30 21:58:14.516042067 +0200
+@@ -41,6 +41,7 @@
+ 
+ #include "qtgafile.h"
+ 
++#include <QtCore/QBuffer>
+ #include <QtCore/QIODevice>
+ #include <QtCore/QDebug>
+ #include <QtCore/QDateTime>
+@@ -264,3 +265,16 @@ QImage QTgaFile::readImage()
+     // TODO: add processing of TGA extension information - ie TGA 2.0 files
+     return im;
+ }
++/**
++ * Checks if device contains a valid tga image, *without* changing device
++ * position.
++ */
++bool QTgaFile::canRead(QIODevice *device)
++{
++	QByteArray header = device->peek(HeaderSize);
++	if (header.size() < HeaderSize)
++		return false;
++	QBuffer buffer(&header);
++	QTgaFile tga(&buffer);
++	return tga.isValid();
++}
+diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h
+--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me	2012-03-30 21:58:39.670023189 +0200
++++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h	2012-03-30 21:59:06.202317384 +0200
+@@ -93,6 +93,8 @@ public:
+     inline QSize size() const;
+     inline Compression compression() const;
+ 
++    static bool canRead(QIODevice *device);
++
+ private:
+     static inline quint16 littleEndianInt(const unsigned char *d);
+ 
+diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp
+--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me	2012-03-30 21:59:17.373303356 +0200
++++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp	2012-03-30 22:00:13.817226439 +0200
+@@ -77,8 +77,7 @@ bool QTgaHandler::canRead(QIODevice *dev
+         qWarning("QTgaHandler::canRead() called with no device");
+         return false;
+     }
+-    QTgaFile tga(device);
+-    return tga.isValid();
++    return QTgaFile::canRead(device);
+ }
+ 
+ bool QTgaHandler::read(QImage *image)
diff --git a/qt.spec b/qt.spec
index 716bfde..d5b7950 100644
--- a/qt.spec
+++ b/qt.spec
@@ -11,7 +11,7 @@ Summary: Qt toolkit
 Name:    qt
 Epoch:   1
 Version: 4.8.1
-Release: 3%{?dist}
+Release: 4%{?dist}
 
 # See LGPL_EXCEPTIONS.txt, LICENSE.GPL3, respectively, for exception details
 License: (LGPLv2 with exceptions or GPLv3 with exceptions) and ASL 2.0 and BSD and FTL and MIT
@@ -106,6 +106,8 @@ Patch80: qt-everywhere-opensource-src-4.8.0-ld-gold.patch
 Patch81: qt-everywhere-opensource-src-4.8.0-gcc-4.7.patch
 
 # upstream patches
+# http://codereview.qt-project.org/#change,22006
+Patch100: qt-everywhere-opensource-src-4.8.1-qtgahandle.patch
 
 # security patches
 # CVE-2011-3922 qt: Stack-based buffer overflow in embedded harfbuzz code
@@ -436,6 +438,7 @@ rm -fv mkspecs/linux-g++*/qmake.conf.multilib-optflags
 %patch81 -p1 -b .gcc-4.7
 
 # upstream patches
+%patch100 -p1 -b .QTgaHandler
 
 # security fixes
 %patch200 -p1 -b .CVE-2011-3922
@@ -1060,6 +1063,9 @@ fi
 
 
 %changelog
+* Fri Mar 30 2012 Than Ngo <than at redhat.com> - 4.8.1-4
+- Fix QTgaHandler::canRead() not obeying image plugin specs
+
 * Thu Mar 29 2012 Rex Dieter <rdieter at fedoraproject.org> 4.8.1-3
 - Header file name mismatch in qt-devel i686 (#808087)
 


More information about the scm-commits mailing list