Skip to content

Dangerous use of .index in Parse Functions (Error on parse_new_issuance_metadata_10007) #46

@tloriato

Description

@tloriato
Traceback (most recent call last):
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/DataStore.py", line 3115, in catch_up
explorernode_1  |     if not store.catch_up_rpc(dircfg):
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/DataStore.py", line 3711, in catch_up_rpc
explorernode_1  |     store.import_block(block, chain = chain)
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/DataStore.py", line 1404, in import_block
explorernode_1  |     tx['tx_id'] = store.import_and_commit_tx(tx, pos == 0, chain)
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/DataStore.py", line 2437, in import_and_commit_tx
explorernode_1  |     tx_id = store.import_tx(tx, is_coinbase, chain)
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/DataStore.py", line 2288, in import_tx
explorernode_1  |     opdrop_type, val = util.parse_op_drop_data(data, chain)
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/util.py", line 426, in parse_op_drop_data
explorernode_1  |     return func(data)
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/util.py", line 439, in parse_op_drop_data_10007
explorernode_1  |     retval = parse_new_issuance_metadata_10007(data[5:])
explorernode_1  |   File "/root/.local/lib/python2.7/site-packages/Mce/util.py", line 753, in parse_new_issuance_metadata_10007
explorernode_1  |     fname = searchdata[:searchdata.index("\0")]
explorernode_1  | ValueError: substring not found

string.index throws an error when it doesn't encounter the specified substring, which is a dangerous behavior. I've been trying to fix this, but I don't completely understand the function yet.

At the time of error:

>print(searchdata)
> nd,receive}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions