--- /dev/null
+libtiff5
+ obsoletes "libtiff-<targettype> <= <version>"
+ provides "libtiff-<targettype> = <version>"
+libtiff-devel
+ requires -libtiff-<targettype>
+ requires "libtiff5-<targettype> = <version>"
--- /dev/null
+Index: tools/tiff2pdf.c
+===================================================================
+--- tools/tiff2pdf.c.orig
++++ tools/tiff2pdf.c
+@@ -1066,6 +1066,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF*
+ "Can't set directory %u of input file %s",
+ i,
+ TIFFFileName(input));
++ t2p->t2p_error = T2P_ERR_ERROR;
+ return;
+ }
+ if(TIFFGetField(input, TIFFTAG_PAGENUMBER, &pagen, &paged)){
--- /dev/null
+diff -urN tiff-4.0.1.orig/libtiff/tif_jpeg.c tiff-4.0.1/libtiff/tif_jpeg.c
+--- tiff-4.0.1.orig/libtiff/tif_jpeg.c 2012-03-29 01:03:15.680848289 +0800
++++ tiff-4.0.1/libtiff/tif_jpeg.c 2012-03-29 01:09:09.212428534 +0800
+@@ -1175,6 +1175,7 @@
+ if (downsampled_output) {
+ /* Need to use raw-data interface to libjpeg */
+ sp->cinfo.d.raw_data_out = TRUE;
++ sp->cinfo.d.do_fancy_upsampling = FALSE;
+ tif->tif_decoderow = DecodeRowError;
+ tif->tif_decodestrip = JPEGDecodeRaw;
+ tif->tif_decodetile = JPEGDecodeRaw;
--- /dev/null
+Index: tiff-4.0.1/libtiff/tiffiop.h
+===================================================================
+--- tiff-4.0.1.orig/libtiff/tiffiop.h
++++ tiff-4.0.1/libtiff/tiffiop.h
+@@ -213,7 +213,7 @@ struct tiff {
+ #define TIFFWriteFile(tif, buf, size) \
+ ((*(tif)->tif_writeproc)((tif)->tif_clientdata,(buf),(size)))
+ #define TIFFSeekFile(tif, off, whence) \
+- ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(off),(whence)))
++ ((tif)->tif_seekproc?((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)):0)
+ #define TIFFCloseFile(tif) \
+ ((*(tif)->tif_closeproc)((tif)->tif_clientdata))
+ #define TIFFGetFileSize(tif) \
--- /dev/null
+diff -urN tiff-4.0.1.orig/tools/tiff2pdf.c tiff-4.0.1/tools/tiff2pdf.c
+--- tiff-4.0.1.orig/tools/tiff2pdf.c 2012-03-29 01:03:15.656848587 +0800
++++ tiff-4.0.1/tools/tiff2pdf.c 2012-03-29 01:03:27.591699381 +0800
+@@ -4991,7 +4991,7 @@
+
+ if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR) {
+ written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13);
+- written += t2pWriteFile(output, (tdata_t) "<< /ColorTransform 0 >>\n", 24);
++ written += t2pWriteFile(output, (tdata_t) "<< /ColorTransform 1 >>\n", 24);
+ }
+ break;
+ #endif
--- /dev/null
+--- tiff-4.0.2/test/raw_decode.c.xx 2012-06-28 11:48:43.000000000 +0200
++++ tiff-4.0.2/test/raw_decode.c 2012-06-28 12:15:46.000000000 +0200
+@@ -85,9 +85,9 @@
+ static int check_rgba_pixel( int pixel, int red, int green, int blue, int alpha, unsigned char *buffer ) {
+ /* RGBA images are upside down - adjust for normal ordering */
+ int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128;
+- unsigned char *rgba = buffer + 4 * adjusted_pixel;
+-
+- if( rgba[0] == red && rgba[1] == green && rgba[2] == blue && rgba[3] == alpha ) {
++ unsigned int *rgba = (unsigned int*)(buffer + 4 * adjusted_pixel);
++
++ if( TIFFGetR(*rgba) == red && TIFFGetG(*rgba) == green && TIFFGetB(*rgba) == blue && TIFFGetA(*rgba) == alpha ) {
+ return 0;
+ }
+
--- /dev/null
+Name: tiff
+#BuildRequires: libjbig-devel
+Version: 4.0.2
+Release: 0
+License: HPND
+Summary: Tools for Converting from and to the Tiff Format
+Url: http://www.remotesensing.org/libtiff
+Group: Productivity/Graphics/Convertors
+Source: tiff-%{version}.tar.bz2
+Source3: baselibs.conf
+Patch2: tiff-%{version}-seek.patch
+Patch3: tiff-%{version}-tiff2pdf-colors.patch
+Patch9: tiff-%{version}-dont-fancy-upsampling.patch
+Patch10: tiff-bigendian.patch
+Patch11: tiff-%{version}-CVE-2012-3401.patch
+BuildRequires: gcc-c++
+BuildRequires: libjpeg8-devel
+BuildRequires: libtool
+BuildRequires: lzma-devel
+BuildRequires: pkg-config
+BuildRequires: pkgconfig(zlib)
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+
+%description
+This package contains the library and support programs for the TIFF
+image format.
+
+%package -n libtiff
+Summary: The Tiff Library (with JPEG and compression support)
+Group: System/Libraries
+
+%description -n libtiff
+This package includes the tiff libraries. To link a program with
+libtiff, you will have to add -ljpeg and -lz to include the necessary
+libjpeg and libz in the linking process.
+
+%package -n libtiff-devel
+Summary: Development Tools for Programs which will use the libtiff Library
+Group: Development/Libraries/C and C++
+Requires: glibc-devel
+Requires: libstdc++-devel
+Requires: libtiff = %{version}
+
+%description -n libtiff-devel
+This package contains the header files and static libraries for
+developing programs which will manipulate TIFF format image files using
+the libtiff library.
+
+%prep
+%setup -q
+%patch2 -p1
+%patch3 -p1
+%patch9 -p1
+%patch10 -p1
+%patch11
+
+%build
+%configure --disable-static --with-pic
+make %{?_smp_mflags}
+
+%install
+mkdir -p %{buildroot}/{%{_mandir}/{man1,man3},usr/{bin,lib,include}}
+%make_install
+for f in `find %{buildroot}/%{_mandir} -type f -print ` ; do
+ if [ `wc -l <$f` -eq 1 ] && grep -q "^\.so " $f ; then
+ linkto=`sed -e "s|^\.so ||" $f`
+ [ -f "`dirname $f`/$linkto" ] && ln -sf "$linkto" $f
+ fi
+done
+
+rm -rf %{buildroot}%{_datadir}/doc/tiff*
+rm -f %{buildroot}/%{_libdir}/*.la
+find html -name "Makefile*" | xargs rm
+
+
+%docs_package
+
+%post -n libtiff -p /sbin/ldconfig
+
+%postun -n libtiff -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%{_bindir}/*
+
+%files -n libtiff
+%doc COPYRIGHT
+%{_libdir}/*.so.*
+
+%files -n libtiff-devel
+%{_includedir}/*
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/*.pc
+
+%changelog