From 3395288dfea45a4b15df8c7b6530f41efdd24e28 Mon Sep 17 00:00:00 2001 From: pataegrillo Date: Sat, 23 Dec 2023 11:05:35 -0400 Subject: [PATCH 1/6] - Now if a broadcast has a malformed text, it gets rejected --- counterpartylib/lib/messages/broadcast.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/counterpartylib/lib/messages/broadcast.py b/counterpartylib/lib/messages/broadcast.py index e254dedf0b..66749331de 100644 --- a/counterpartylib/lib/messages/broadcast.py +++ b/counterpartylib/lib/messages/broadcast.py @@ -169,7 +169,10 @@ def parse (db, tx, message): except (struct.error) as e: timestamp, value, fee_fraction_int, text = 0, None, 0, None status = 'invalid: could not unpack' - + except AssertionError: + timestamp, value, fee_fraction_int, text = 0, None, 0, None + status = "invalid: could not unpack text" + if status == 'valid': # For SQLite3 timestamp = min(timestamp, config.MAX_INT) From 33a136e5b5c2935bb8f7218799c3cee6a496cadd Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Tue, 27 Feb 2024 17:59:21 +0100 Subject: [PATCH 2/6] Fix integer overflow in dispensers --- counterpartylib/lib/messages/dispenser.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/counterpartylib/lib/messages/dispenser.py b/counterpartylib/lib/messages/dispenser.py index 3eb06e5142..9e3b38a418 100644 --- a/counterpartylib/lib/messages/dispenser.py +++ b/counterpartylib/lib/messages/dispenser.py @@ -202,15 +202,18 @@ def validate (db, source, asset, give_quantity, escrow_quantity, mainchainrate, problems.append('cannot dispense %s' % asset) # How can we test this on a test vector? else: problems.append('address has already a dispenser about to close, no action can be taken until it closes') - + cursor.close() - + if oracle_address is not None and util.enabled('oracle_dispensers', block_index): last_price, last_fee, last_label, last_updated = util.get_oracle_last_price(db, oracle_address, block_index) - + if last_price is None: problems.append('The oracle address %s has not broadcasted any price yet' % oracle_address) - + + if give_quantity > config.MAX_INT or escrow_quantity > config.MAX_INT or mainchainrate > config.MAX_INT: + problems.append('integer overflow') + if len(problems) > 0: return None, problems else: From 4c90f2dbb2a9bf845f9cb9280d591d3f83b024fa Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Tue, 27 Feb 2024 18:00:44 +0100 Subject: [PATCH 3/6] Bump version --- counterpartylib/lib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/counterpartylib/lib/config.py b/counterpartylib/lib/config.py index 0378641ba6..775b6327b1 100644 --- a/counterpartylib/lib/config.py +++ b/counterpartylib/lib/config.py @@ -9,7 +9,7 @@ # Versions VERSION_MAJOR = 9 VERSION_MINOR = 61 -VERSION_REVISION = 1 +VERSION_REVISION = 2 VERSION_STRING = str(VERSION_MAJOR) + '.' + str(VERSION_MINOR) + '.' + str(VERSION_REVISION) From 409bdb926e29d656c6c98229a476e9e455c4920d Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Tue, 27 Feb 2024 18:03:24 +0100 Subject: [PATCH 4/6] Update ChangeLog.md --- ChangeLog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 2cb494d5bc..40503c5852 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,7 @@ ## Library Versions ## +* v9.61.2 (2024-02-28) + * Fix integer overflow in dispensers. + * Invalidate broadcast with malformed text. * v9.60.0 (2022-08-29) * Removed `callable`,`call_date`, and `call_price` from issuances * Added support for CIP24 (Oracled Dispensers) From 0287ecfdb7ebbc91b68fc05ddefcd2b65e092ac8 Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Tue, 27 Feb 2024 18:23:45 +0100 Subject: [PATCH 5/6] Fix Logging for Destructions with Invalid Asset --- counterpartylib/lib/log.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/counterpartylib/lib/log.py b/counterpartylib/lib/log.py index 9ffb04ac8c..0511f24aa7 100644 --- a/counterpartylib/lib/log.py +++ b/counterpartylib/lib/log.py @@ -384,10 +384,13 @@ def output (quantity, asset): logger.info('Expired RPS Match: {}'.format(bindings['rps_match_id'])) elif category == 'destructions': - asset_info = get_asset_info(cursor, bindings['asset']) - quantity = bindings['quantity'] - if asset_info['divisible']: - quantity = "{:.8f}".format(quantity/config.UNIT) + try: + asset_info = get_asset_info(cursor, bindings['asset']) + quantity = bindings['quantity'] + if asset_info['divisible']: + quantity = "{:.8f}".format(quantity/config.UNIT) + except IndexError as e: + quantity = '?' logger.info('Destruction: {} destroyed {} {} with tag ‘{}’({}) [{}]'.format(bindings['source'], quantity, bindings['asset'], bindings['tag'], bindings['tx_hash'], bindings['status'])) From 98171e34bb93c03c81274d15e43d1a6fbcc691d7 Mon Sep 17 00:00:00 2001 From: Ouziel Slama Date: Tue, 27 Feb 2024 18:37:10 +0100 Subject: [PATCH 6/6] Update ChangeLog.md --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 40503c5852..cd4683a7fb 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ * v9.61.2 (2024-02-28) * Fix integer overflow in dispensers. * Invalidate broadcast with malformed text. + * Fix Logging for Destructions with Invalid Asset. * v9.60.0 (2022-08-29) * Removed `callable`,`call_date`, and `call_price` from issuances * Added support for CIP24 (Oracled Dispensers)