Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Sign in
common
common
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar

新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

  • chainmaker
  • commoncommon
  • Issues
  • #3

Closed
Open
Opened Mar 24, 2025 by Ligueston Guest@hkuclion

EVMString pack方法的十六进制正则匹配

在 evmutils/abi/burrow/abi/primitives.go 中 第 725行定义了 EVMString的pack方法

func (e EVMString) pack(v interface{}) ([]byte, error) {
	b := EVMBytes{M: 0}

	return b.pack(v)
}

直接交由EVMBytes进行pack,没有携带来源参数

第 617行定义了 var reghex = regexp.MustCompile("0[xX][0-9a-fA-F]+") 然后在 625行 附近使用了EVMBytes的pack方法

//如果是16进制,则进行转换
			if reghex.MatchString(s) {
				b, _ = hex.DecodeString(s[2:])
			} else {
				b = []byte(s)
			}

由于正则表达式没有匹配字符串的开始以及结尾, 导致形如 "test:0x1234567890abcdef" 这样的字符串也会进入到if中, 然后取出"st:0x1234567890abcdef"去做十六进制解析导致失败。 当然就算已经处理了, 在实际情况就是想要把 "0x1234567890abcdef" 作为字符串参数时, 也会被当作bytes来pack而报错。

在EVMString的pack中,先把v转换成[]byte应该能解决这个问题

Edited Mar 24, 2025 by Ligueston Guest
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: chainmaker/common#3

Copyright © 2021 ChainMaker Org. All Rights Reserved. 长安链 版权所有。