Backported patch unexpected version string length error in windres (RHBZ #902960)

This commit is contained in:
Erik van Pienbroek 2013-01-22 21:03:56 +01:00
parent deef2d081d
commit 21c00241c5
2 changed files with 79 additions and 2 deletions

View File

@ -0,0 +1,69 @@
From: Kai Tietz <kai.tietz@onevision.com>
Date: Wed, 28 Nov 2012 15:53:37 +0000 (+0000)
Subject: * resbin.c (bin_to_res_version): Correct offset
X-Git-Tag: binutils_latest_snapshot~48
X-Git-Url: http://sourceware.org/git/?p=binutils.git;a=commitdiff_plain;h=260cd95271cdf002ed8e419898fd29c42e257841
* resbin.c (bin_to_res_version): Correct offset
and length calculation of resource.
(get_version_header): Apply alignement of 4 to len.
---
diff --git a/binutils/resbin.c b/binutils/resbin.c
index b5dcd9b..548ff38 100644
--- a/binutils/resbin.c
+++ b/binutils/resbin.c
@@ -909,7 +909,7 @@ get_version_header (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt
if (length < 8)
toosmall (key);
- *len = windres_get_16 (wrbfd, data, 2);
+ *len = (windres_get_16 (wrbfd, data, 2) + 3) & ~3;
*vallen = windres_get_16 (wrbfd, data + 2, 2);
*type = windres_get_16 (wrbfd, data + 4, 2);
@@ -1041,10 +1041,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt
data += off;
length -= off;
- /* It's convenient to round verlen to a 4 byte alignment,
- since we round the subvariables in the loop. */
-
- verlen = (verlen + 3) &~ 3;
+ verlen -= off;
vi->u.string.stringtables = NULL;
ppvst = &vi->u.string.stringtables;
@@ -1070,7 +1067,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt
length -= off;
verlen -= off;
- stverlen = (stverlen + 3) &~ 3;
+ stverlen -= off;
vst->strings = NULL;
ppvs = &vst->strings;
@@ -1088,14 +1085,12 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt
get_version_header (wrbfd, data, length, (const char *) NULL,
&vs->key, &sverlen, &vallen, &type, &off);
- sverlen = (sverlen + 3) &~ 3;
-
data += off;
length -= off;
vs->value = get_unicode (wrbfd, data, length, &vslen);
valoff = vslen * 2 + 2;
- valoff = (valoff + 3) &~ 3;
+ valoff = (valoff + 3) & ~3;
if (off + valoff != sverlen)
fatal (_("unexpected version string length %ld != %ld + %ld"),
@@ -1108,6 +1103,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt
fatal (_("unexpected version string length %ld < %ld"),
(long) verlen, (long) sverlen);
stverlen -= sverlen;
+ verlen -= sverlen;
vs->next = NULL;
*ppvs = vs;

View File

@ -2,7 +2,7 @@
Name: mingw-binutils
Version: 2.23.51.0.5
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Cross-compiled version of binutils for Win32 and Win64 environments
License: GPLv2+ and LGPLv2+ and GPLv3+ and LGPLv3+
@ -22,7 +22,11 @@ BuildRequires: mingw64-filesystem >= 95
BuildRequires: dejagnu
BuildRequires: sharutils
%endif
Provides: bundled(libiberty)
Provides: bundled(libiberty)
# Resolves: *-mingw32-windres: unexpected version string length 68 != 32 + 8
# https://bugzilla.redhat.com/show_bug.cgi?id=902960
Patch0: binutils.git-260cd95271cdf002ed8e419898fd29c42e257841.patch
%description
@ -61,6 +65,7 @@ understand Windows executables and DLLs.
%prep
%setup -q -n binutils-%{version}
%patch0 -p1
%build
@ -247,6 +252,9 @@ rm -rf $RPM_BUILD_ROOT/multilib
%changelog
* Tue Jan 22 2013 Erik van Pienbroek <epienbro@fedoraproject.org> - 2.23.51.0.5-3
- Backported patch to fix 'unexpected version string length' error in windres (RHBZ #902960)
* Tue Nov 27 2012 Erik van Pienbroek <epienbro@fedoraproject.org> - 2.23.51.0.5-2
- Added BR: zlib-devel to enable support for compressed debug sections