diff --git a/ChangeLog.md b/ChangeLog.md index 2cb494d5bc..cd4683a7fb 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,8 @@ ## Library Versions ## +* 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) 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) 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'])) 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) 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: