aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Tietz <kai.tietz@onevision.com>2012-11-28 15:53:37 +0000
committerKai Tietz <kai.tietz@onevision.com>2012-11-28 15:53:37 +0000
commitfb98f7b7824bd394d64f56e6aa05436f8c1a7c6c (patch)
tree1b43b4aa5e33b10e43da660d7c483536a64050b3
parent7e20dfcd947ceb8b6f48863e9bae82205a63cc8a (diff)
downloadgdb-fb98f7b7824bd394d64f56e6aa05436f8c1a7c6c.zip
gdb-fb98f7b7824bd394d64f56e6aa05436f8c1a7c6c.tar.gz
gdb-fb98f7b7824bd394d64f56e6aa05436f8c1a7c6c.tar.bz2
* resbin.c (bin_to_res_version): Correct offset
and length calculation of resource. (get_version_header): Apply alignement of 4 to len.
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/resbin.c14
2 files changed, 11 insertions, 9 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index a763235..46fda07 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-27 Kai Tietz <ktietz@redhat.com>
+
+ * resbin.c (bin_to_res_version): Correct offset
+ and length calculation of resource.
+ (get_version_header): Apply alignement of 4 to len.
+
2012-11-16 H.J. Lu <hongjiu.lu@intel.com>
* readelf.c (process_dynamic_section): Correct DF_1_CONFALT.
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;