Skip to content
This repository was archived by the owner on Nov 26, 2019. It is now read-only.
This repository was archived by the owner on Nov 26, 2019. It is now read-only.

aborts when ARGV contains non-utf8 characters #11

@keroro520

Description

@keroro520

c/{entry.c,argv_entry.c,argv_source_entry.c} ignores non-utf8 characters in ARGV.

for (int i = 2; i < argc; i++) {
    char* utf8 = mrb_utf8_from_locale(argv[i], -1);
    if (utf8) {
      mrb_ary_push(mrb, margv, mrb_str_new_cstr(mrb, utf8));
      mrb_utf8_free(utf8);
    }
  }

What I concern about is, is it possible that cause inconsistency? That is undesired on blockchain. For example, Alice write a lock-script like

left = "我是个非UTF8的字符串"
hash = "12345678901234567890"

right =  $UNLOCK_ARGUMENT[1]
return hash(left, right) == hash

Alice has to provide an unlock argument $UNLOCK_ARGUMENT, which meets the hash condition, to unlock the lock-script above. But since left is an non-utf8 string, the hash results of Alice computes offline and CKB-VM are difference. Then Alice has no way to unlock that script.

So, I think aborting for non-utf8 may be better here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions