public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Tobin Harding <me@tobin.cc>
To: bitcoindev@googlegroups.com
Cc: "Andrew Poelstra" <apoelstra@wpsoftware.net>,
	"Martin Habovštiak" <martin.habovstiak@gmail.com>
Subject: [bitcoindev] ReadCompactSize without range check
Date: Tue, 3 Sep 2024 09:18:05 +1000	[thread overview]
Message-ID: <ZtZHrc3XvTXEvHf6@alke> (raw)

Hi,

Context:

- The `ReadCompactSize` function takes an optional `range_check`
  parameter that defaults to `true` (see `serialize.h`).
- `range_check == true` enforces that the compact size value is less
  than 0x02000000 i.e., if fits within a 32 unsigned integer.
- Grepping the code base shows that `ReadCompactSize` is never called
  with `false`.

My question is please:

Is there any reason not use a 32 bit integer for a value encoded using
CompactSize and ignore the 0xFF/9-byte-encoding of a compact size all
together?

Thanks,
Tobin.

-- 
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/ZtZHrc3XvTXEvHf6%40alke.


                 reply	other threads:[~2024-09-02 23:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZtZHrc3XvTXEvHf6@alke \
    --to=me@tobin.cc \
    --cc=apoelstra@wpsoftware.net \
    --cc=bitcoindev@googlegroups.com \
    --cc=martin.habovstiak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox