From 548a23572832015e1d457188c5962e349825e86e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 17 Jun 2014 16:50:15 +0100 Subject: [PATCH] Prevent large (or negative) version values from overflowing into other fields when parsing version strings. PR binutils/16923 * rcparse.y (fixedverinfo): Prevent large version numbers from corrupting other values. --- binutils/ChangeLog | 6 ++++++ binutils/rcparse.y | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 50cb6cc5b33..71eca314fa2 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2014-06-17 Anton Lavrentiwev + + PR binutils/16923 + * rcparse.y (fixedverinfo): Prevent large version numbers from + corrupting other values. + 2014-06-09 Romain Chastenet PR binutils/16252 diff --git a/binutils/rcparse.y b/binutils/rcparse.y index f552ce5a65b..2d179097fc0 100644 --- a/binutils/rcparse.y +++ b/binutils/rcparse.y @@ -1425,15 +1425,15 @@ fixedverinfo: | fixedverinfo FILEVERSION numexpr optcnumexpr optcnumexpr optcnumexpr { - $1->file_version_ms = ($3 << 16) | $4; - $1->file_version_ls = ($5 << 16) | $6; + $1->file_version_ms = ($3 << 16) | ($4 & 0xffff); + $1->file_version_ls = ($5 << 16) | ($6 & 0xffff); $$ = $1; } | fixedverinfo PRODUCTVERSION numexpr optcnumexpr optcnumexpr optcnumexpr { - $1->product_version_ms = ($3 << 16) | $4; - $1->product_version_ls = ($5 << 16) | $6; + $1->product_version_ms = ($3 << 16) | ($4 & 0xffff); + $1->product_version_ls = ($5 << 16) | ($6 & 0xffff); $$ = $1; } | fixedverinfo FILEFLAGSMASK numexpr -- 2.30.2