/* resbin.c -- manipulate the Windows binary resource format.
- Copyright 1997, 1998, 1999, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 1997-2014 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
Rewritten by Kai Tietz, Onevision.
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);
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;
length -= off;
verlen -= off;
- stverlen = (stverlen + 3) &~ 3;
+ stverlen -= off;
vst->strings = NULL;
ppvs = &vst->strings;
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"),
fatal (_("unexpected version string length %ld < %ld"),
(long) verlen, (long) sverlen);
stverlen -= sverlen;
+ verlen -= sverlen;
vs->next = NULL;
*ppvs = vs;