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

Verify supplied hash in JSON I/O #2159

Merged
merged 1 commit into from Apr 24, 2017
Merged

Verify supplied hash in JSON I/O #2159

merged 1 commit into from Apr 24, 2017

Conversation

axic
Copy link
Member

@axic axic commented Apr 22, 2017

Fixes #2158.

@axic axic requested a review from chriseth April 24, 2017 10:27
@@ -91,6 +92,21 @@ Json::Value formatErrorWithException(
return formatError(_warning, _type, _component, message, formattedMessage, location);
}

/// @_hash contains a Keccak256 hash with the 0x prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be @param _hash contains... and I think the main description should be in the first line. I usually just mention the params in the description to avoid redundancy (redundancy often makes you take longer to grasp what it does)

Returns true iff @a _hash (hex with 0x prefix) is the Keccak256 hash of the binary data in @a _content.

Is the 0x prefix required?

Copy link
Member Author

Choose a reason for hiding this comment

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

0x is required by the spec, could be changed though.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is @a _hash ? Isn't @_hash working?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, not as far as I know. @a tells the doxygen parser that the following word is a function argument.

Copy link
Member Author

@axic axic Apr 24, 2017

Choose a reason for hiding this comment

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

Actually, we can make a decision whether the hash should be prefixed with 0x or not. Usually hashes are not prefixed and the other URLs (swarm) which use them do not prefix them either.

@@ -165,8 +181,24 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
Json::Value errors = Json::arrayValue;

for (auto const& sourceName: sources.getMemberNames())
{
string hash = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

This assignment is not required.

if (sources[sourceName]["content"].isString())
m_compilerStack.addSource(sourceName, sources[sourceName]["content"].asString());
{
string const& content = sources[sourceName]["content"].asString();
Copy link
Contributor

Choose a reason for hiding this comment

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

You cannot store by reference if the function returns by value.

false,
"IOError",
"general",
"Mismatch between content and supplied hash for \"" + url.asString() + "\""
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide the file name and the url? The url might just be a cryptic swarm hash.

@chriseth chriseth merged commit 2c3fea5 into develop Apr 24, 2017
@axic axic deleted the jsonio-source-verify branch April 24, 2017 14:22
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.

None yet

2 participants