Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly treat utf8-non-encodable yul literals. #11338

Merged
merged 2 commits into from
May 5, 2021
Merged

Conversation

chriseth
Copy link
Contributor

@chriseth chriseth commented May 3, 2021

References #11324

@chriseth chriseth requested review from axic, aarlt and cameel May 3, 2021 12:28
@chriseth
Copy link
Contributor Author

chriseth commented May 3, 2021

Should be fixed now.

lit.value = YulString{member(_node, "value").asString()};
solAssert(member(_node, "hexValue").isString() || member(_node, "value").isString(), "");
if (_node.isMember("hexValue"))
lit.value = YulString{util::asString(util::fromHex(member(_node, "hexValue").asString()))};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to also use util::validateUTF8 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, why? Literals can be invalid utf8

Changelog.md Outdated
@@ -10,6 +10,11 @@ Compiler Features:


Bugfixes:
* AST: Do not output value of Yul literal if it is not valid utf8.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* AST: Do not output value of Yul literal if it is not valid utf8.
* AST: Do not output value of Yul literal if it is not a valid utf8 string.

@chriseth
Copy link
Contributor Author

chriseth commented May 4, 2021

Rebased and updated changelog.

@@ -68,6 +68,7 @@
"src": "79:6:1",
"value":
{
"hexValue": "37",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value is 7, but hexValue is 37?

ret["value"] = _node.value.str();
else
ret["value"] = Json::nullValue;
ret["hexValue"] = util::toHex(util::asBytes(_node.value.str()));
Copy link
Member

@hrkrshnn hrkrshnn May 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's an integer literal, should the hex value go through the byte-string conversion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you are right, we should only have hexValue for string literals.

@hrkrshnn hrkrshnn enabled auto-merge May 5, 2021 08:44
@hrkrshnn hrkrshnn merged commit 6820735 into develop May 5, 2021
@hrkrshnn hrkrshnn deleted the yulhexvalue branch May 5, 2021 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants