work around gcc 4.8.0 issue on ppc64 (#915321)

This commit is contained in:
Jiri Popelka 2013-03-05 11:37:57 +01:00
parent dd3ffca474
commit 81301bbb2d
3 changed files with 86 additions and 1 deletions

View File

@ -0,0 +1,61 @@
diff -urN ../qpdf-4.0.1.orig/ChangeLog ./ChangeLog
--- ../qpdf-4.0.1.orig/ChangeLog 2013-01-17 14:51:04.000000000 +0000
+++ ./ChangeLog 2013-03-04 21:15:53.952108469 +0000
@@ -1,3 +1,13 @@
+2013-02-23 Jay Berkenbilt <ejb@ql.org>
+
+ * Bug fix: properly handle overridden compressed objects. When
+ caching objects from an object stream, only cache objects that,
+ based on the xref table, would actually be resolved into this
+ stream. Prior to this fix, if an object stream A contained an
+ object B that was overridden by an appended section of the file,
+ qpdf would cache the old value of B if any non-overridden member
+ of A was accessed before B. This commit fixes that bug.
+
2013-01-17 Jay Berkenbilt <ejb@ql.org>
* 4.0.1: release
diff -urN ../qpdf-4.0.1.orig/libqpdf/QPDF.cc ./libqpdf/QPDF.cc
--- ../qpdf-4.0.1.orig/libqpdf/QPDF.cc 2013-01-17 14:51:04.000000000 +0000
+++ ./libqpdf/QPDF.cc 2013-03-04 21:15:53.952108469 +0000
@@ -1538,20 +1538,31 @@
offsets[num] = offset + first;
}
+ // To avoid having to read the object stream multiple times, store
+ // all objects that would be found here in the cache. Remember
+ // that some objects stored here might have been overridden by new
+ // objects appended to the file, so it is necessary to recheck the
+ // xref table and only cache what would actually be resolved here.
for (std::map<int, int>::iterator iter = offsets.begin();
iter != offsets.end(); ++iter)
{
int obj = (*iter).first;
- int offset = (*iter).second;
- input->seek(offset, SEEK_SET);
- QPDFObjectHandle oh = readObject(input, "", obj, 0, true);
-
- // Store in cache
ObjGen og(obj, 0);
-
- this->obj_cache[og] =
- ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh),
- end_before_space, end_after_space);
+ QPDFXRefEntry const& entry = this->xref_table[og];
+ if ((entry.getType() == 2) &&
+ (entry.getObjStreamNumber() == obj_stream_number))
+ {
+ int offset = (*iter).second;
+ input->seek(offset, SEEK_SET);
+ QPDFObjectHandle oh = readObject(input, "", obj, 0, true);
+ this->obj_cache[og] =
+ ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh),
+ end_before_space, end_after_space);
+ }
+ else
+ {
+ //QTC::TC("qpdf", "QPDF not caching overridden objstm object");
+ }
}
}

12
qpdf-size_t.patch Normal file
View File

@ -0,0 +1,12 @@
diff -urN ../qpdf-4.0.1.orig/qpdf/qpdf.cc ./qpdf/qpdf.cc
--- ../qpdf-4.0.1.orig/qpdf/qpdf.cc 2013-01-17 14:51:04.000000000 +0000
+++ ./qpdf/qpdf.cc 2013-03-04 21:07:56.361335897 +0000
@@ -1574,7 +1574,7 @@
// This prevents those objects from being preserved by
// being referred to from other places, such as the
// outlines dictionary.
- for (int pageno = 0; pageno < (int)orig_pages.size(); ++pageno)
+ for (size_t pageno = 0; pageno < orig_pages.size(); ++pageno)
{
if (selected_from_orig.count(pageno) == 0)
{

View File

@ -1,12 +1,15 @@
Summary: Command-line tools and library for transforming PDF files
Name: qpdf
Version: 4.0.1
Release: 2%{?dist}
Release: 3%{?dist}
License: Artistic 2.0
Group: System Environment/Base
URL: http://qpdf.sourceforge.net/
Source0: http://downloads.sourceforge.net/sourceforge/qpdf/qpdf-%{version}.tar.gz
Patch0: qpdf-size_t.patch
Patch1: qpdf-compressed-object.patch
BuildRequires: zlib-devel
BuildRequires: pcre-devel
@ -58,6 +61,11 @@ QPDF Manual
%prep
%setup -q
# work around gcc 4.8.0 issue on ppc64 (#915321)
%patch0 -p1 -b .size_t
# properly handle overridden compressed objects
%patch1 -p1 -b .compressed-object
%build
# work-around check-rpaths errors
autoreconf --verbose --force --install
@ -102,6 +110,10 @@ make check
%doc __doc/*
%changelog
* Tue Mar 05 2013 Jiri Popelka <jpopelka@redhat.com> - 4.0.1-3
- work around gcc 4.8.0 issue on ppc64 (#915321)
- properly handle overridden compressed objects
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild