diff options
author | Wladimir <laanwj@gmail.com> | 2014-10-14 10:04:20 +0200 |
---|---|---|
committer | bitcoindev <bitcoindev@gnusha.org> | 2014-10-14 08:04:27 +0000 |
commit | 2a9300a2d1957bf33aa777c0bf6ebcca9ebc85f8 (patch) | |
tree | 54d7651a790300d99dfe021f29c4720e899c549d | |
parent | ff20b2be0db3047942d84afca6316a0be3468934 (diff) | |
download | pi-bitcoindev-2a9300a2d1957bf33aa777c0bf6ebcca9ebc85f8.tar.gz pi-bitcoindev-2a9300a2d1957bf33aa777c0bf6ebcca9ebc85f8.zip |
Re: [Bitcoin-development] Malleable booleans
-rw-r--r-- | 0d/44c0825af8565aadee0db7fccd8ff9cad8a661 | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/0d/44c0825af8565aadee0db7fccd8ff9cad8a661 b/0d/44c0825af8565aadee0db7fccd8ff9cad8a661 new file mode 100644 index 000000000..bab97cdb1 --- /dev/null +++ b/0d/44c0825af8565aadee0db7fccd8ff9cad8a661 @@ -0,0 +1,101 @@ +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 <laanwj@gmail.com>) 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 <bitcoin-development@lists.sourceforge.net>; + 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: <CAPg+sBjbeAaTmEvqrHHU4Mb45VPyRvFxdRzz1S6+-t7ep20ZtQ@mail.gmail.com> + <201410140927.36252.thomas@thomaszander.se> +Date: Tue, 14 Oct 2014 10:04:20 +0200 +Message-ID: <CA+s+GJBvOH9cW_yaK7ZEDUYznDe=KeoMYMZ3KF=P503JceWFeg@mail.gmail.com> +From: Wladimir <laanwj@gmail.com> +To: Thomas Zander <thomas@thomaszander.se> +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 <bitcoin-development@lists.sourceforge.net> +Subject: Re: [Bitcoin-development] Malleable booleans +X-BeenThere: bitcoin-development@lists.sourceforge.net +X-Mailman-Version: 2.1.9 +Precedence: list +List-Id: <bitcoin-development.lists.sourceforge.net> +List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>, + <mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe> +List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development> +List-Post: <mailto:bitcoin-development@lists.sourceforge.net> +List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help> +List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>, + <mailto:bitcoin-development-request@lists.sourceforge.net?subject=subscribe> +X-List-Received-Date: Tue, 14 Oct 2014 08:04:27 -0000 + +On Tue, Oct 14, 2014 at 9:27 AM, Thomas Zander <thomas@thomaszander.se> 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 <stdio.h> + +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 + + |