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

What happens if _voteOption is something other than 0 or 1? #28

Open
kangarang opened this issue Mar 19, 2018 · 1 comment
Open

What happens if _voteOption is something other than 0 or 1? #28

kangarang opened this issue Mar 19, 2018 · 1 comment

Comments

@kangarang
Copy link
Contributor

kangarang commented Mar 19, 2018

https://github.com/ConsenSys/PLCRVoting/blob/master/contracts/PLCRVoting.sol#L174

function revealVote(uint _pollID, uint _voteOption, uint _salt) external {
    // Make sure the reveal period is active
    require(revealPeriodActive(_pollID));
    require(!hasBeenRevealed(msg.sender, _pollID));                        // prevent user from revealing multiple times
    require(keccak256(_voteOption, _salt) == getCommitHash(msg.sender, _pollID)); // compare resultant hash from inputs to original commitHash

    uint numTokens = getNumTokens(msg.sender, _pollID); 

    if (_voteOption == 1) // apply numTokens to appropriate poll choice
        pollMap[_pollID].votesFor += numTokens;
    else
        pollMap[_pollID].votesAgainst += numTokens;
    
    dllMap[msg.sender].remove(_pollID); // remove the node referring to this vote upon reveal

    VoteRevealed(msg.sender, _pollID, numTokens, _voteOption);
}
@skmgoldin
Copy link
Contributor

Prospective fix: Change else to else if (vote == 0), followed by an else { revert }. The user will never be able to reveal, but they will be able to rescue tokens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants