X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fresbin.c;h=cd562a550e9dc82a0a72085b02510bf3e940865d;hb=6ae978f133a67d34d01b6bb2053f1ba20ad13eeb;hp=8b12649fd55507f7543f9820ef5bc9d280c4f20f;hpb=3aade68889268c7d15e121d6d63cb1b753ec12fa;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/resbin.c b/binutils/resbin.c index 8b12649fd5..cd562a550e 100644 --- a/binutils/resbin.c +++ b/binutils/resbin.c @@ -1,5 +1,5 @@ /* resbin.c -- manipulate the Windows binary resource format. - Copyright (C) 1997-2015 Free Software Foundation, Inc. + Copyright (C) 1997-2019 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. Rewritten by Kai Tietz, Onevision. @@ -574,8 +574,6 @@ bin_to_res_dialog (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type length dc->data = NULL; else { - off = (off + 3) &~ 3; - if (length < off + datalen) toosmall (_("dialog control data")); @@ -961,9 +959,10 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt get_version_header (wrbfd, data, length, "VS_VERSION_INFO", (unichar **) NULL, &verlen, &vallen, &type, &off); - if ((unsigned int) verlen != length) - fatal (_("version length %d does not match resource length %lu"), - (int) verlen, (unsigned long) length); + /* PR 17512: The verlen field does not include padding length. */ + if (verlen > length) + fatal (_("version length %lu greater than resource length %lu"), + (unsigned long) verlen, (unsigned long) length); if (type != 0) fatal (_("unexpected version type %d"), (int) type); @@ -1164,8 +1163,15 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, rc_uint_type lengt vallen -= 4; } } + else if (ch == 0) + { + if (length == 8) + /* Padding - skip. */ + break; + fatal (_("nul bytes found in version string")); + } else - fatal (_("unexpected version string")); + fatal (_("unexpected version string character: %x"), ch); vi->next = NULL; *pp = vi; @@ -1574,7 +1580,6 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog { rc_uint_type saved_off = off; rc_uint_type old_off; - off += (4 - ((off - off_delta) & 3)) & 3; old_off = off; off = res_to_bin_rcdata (wrbfd, off, dc->data); @@ -1582,10 +1587,10 @@ res_to_bin_dialog (windres_bfd *wrbfd, rc_uint_type off, const rc_dialog *dialog old_off = off = saved_off; if (wrbfd) windres_put_16 (wrbfd, dc_rclen, off - old_off); - } + } if (wrbfd) set_windres_bfd_content (wrbfd, dc_rclen, marker, 2); - } + } if (wrbfd) {