From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xdx5n-0004oI-Bu for bitcoin-development@lists.sourceforge.net; Tue, 14 Oct 2014 08:04:27 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.213.174 as permitted sender) client-ip=209.85.213.174; envelope-from=laanwj@gmail.com; helo=mail-ig0-f174.google.com; Received: from mail-ig0-f174.google.com ([209.85.213.174]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Xdx5l-0000Us-Fc for bitcoin-development@lists.sourceforge.net; Tue, 14 Oct 2014 08:04:27 +0000 Received: by mail-ig0-f174.google.com with SMTP id a13so13553121igq.13 for ; Tue, 14 Oct 2014 01:04:20 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.43.140.198 with SMTP id jb6mr3650015icc.34.1413273860163; Tue, 14 Oct 2014 01:04:20 -0700 (PDT) Received: by 10.64.141.112 with HTTP; Tue, 14 Oct 2014 01:04:20 -0700 (PDT) In-Reply-To: <201410140927.36252.thomas@thomaszander.se> References: <201410140927.36252.thomas@thomaszander.se> Date: Tue, 14 Oct 2014 10:04:20 +0200 Message-ID: From: Wladimir To: Thomas Zander Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.3 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (laanwj[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.3 URIBL_RHS_DOB Contains an URI of a new domain (Day Old Bread) [URIs: thomaszander.se] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1Xdx5l-0000Us-Fc Cc: Bitcoin Dev Subject: Re: [Bitcoin-development] Malleable booleans X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2014 08:04:27 -0000 On Tue, Oct 14, 2014 at 9:27 AM, Thomas Zander wro= te: > On Tuesday 14. October 2014 04.34.16 Pieter Wuille wrote: >> This means that scripts that use booleans as inputs will be inherently >> malleable. > > I've ran into this issue in C++ often enough, > a funny example is assigning "2" to a native c++ bool and then you can do= a > if (myBool =3D=3D true) > else if (myBool =3D=3D false) > and neither of them will hit. Off topic nit: I think you're confused with custom BOOL typedefs in C? C++ booleans are protected against this (C++ standard =C2=A74.7/4 according to Google).: ``` #include int main() { bool myBool; myBool =3D 2; if (myBool =3D=3D true) printf("It is true!\n"); else if (myBool =3D=3D false) printf("It is false!\n"); else printf("It is something else!\n"); } ``` Prints 'It is true'. You can also use bool(something) as equivalent of `x !=3D 0`; as in `assert(bool(2) =3D=3D true);`. Wladimir