[patch windres]: Fix binary import of version-info resource

Kai Tietz ktietz70@googlemail.com
Tue Nov 27 09:38:00 GMT 2012


Hi,

This patch fixes a quirk about index/length calculation for binary
versioninfo-resource.
Eg for cygwin the following command './windres.exe
/cygdrive/c/Windows/System32/ntdll.dll' failed in
importing version-resource from system-DLL.

ChangeLog

2012-11-27  Kai Tietz

	* resbin.c (bin_to_res_version):  Correct offset
	and length calculation of resource.

Tested for x86_64-w64-mingw32, i686-pc-cygwin, and i686-w64-mingw32.
Ok for apply?

Regards,
Kai

Index: resbin.c
===================================================================
RCS file: /cvs/src/src/binutils/resbin.c,v
retrieving revision 1.18
diff -p -u -r1.18 resbin.c
--- resbin.c	11 Oct 2011 15:56:28 -0000	1.18
+++ resbin.c	27 Nov 2012 09:34:48 -0000
@@ -1045,6 +1045,7 @@ bin_to_res_version (windres_bfd *wrbfd,
              since we round the subvariables in the loop.  */

 	  verlen = (verlen + 3) &~ 3;
+	  verlen -= off;

 	  vi->u.string.stringtables = NULL;
 	  ppvst = &vi->u.string.stringtables;
@@ -1071,6 +1072,7 @@ bin_to_res_version (windres_bfd *wrbfd,
 	      verlen -= off;

 	  stverlen = (stverlen + 3) &~ 3;
+	  stverlen -= off;

 	  vst->strings = NULL;
 	  ppvs = &vst->strings;
@@ -1108,6 +1110,7 @@ bin_to_res_version (windres_bfd *wrbfd,
 		fatal (_("unexpected version string length %ld < %ld"),
 		       (long) verlen, (long) sverlen);
 	      stverlen -= sverlen;
+	      verlen -= sverlen;

 	      vs->next = NULL;
 	      *ppvs = vs;



More information about the Binutils mailing list