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

False positive on string variable assignment #1752

Open
PiotrNestor opened this issue Mar 30, 2023 · 0 comments
Open

False positive on string variable assignment #1752

PiotrNestor opened this issue Mar 30, 2023 · 0 comments

Comments

@PiotrNestor
Copy link

Description

Analysing with the latest Docker version a simple HelloWorld contract.
The analysis reports some false positive for string variable assignments

How to Reproduce

// SPDX-License-Identifier: MIT
pragma solidity >=0.7.3;

contract HelloWorld {

   event UpdatedMessages(string oldStr, string newStr);
   string public message;

   constructor(string memory initMessage) {
      message = initMessage;
   }

   function update(string memory newMessage) public {
      string memory oldMsg = message;
      message = newMessage;
      emit UpdatedMessages(oldMsg, newMessage);
   }
}

In the report:

==== Integer Arithmetic Bugs ====
SWC ID: 101
Severity: High
Contract: HelloWorld
Function name: update(string)
PC address: 395
Estimated Gas Usage: 21046 - 86946
The arithmetic operator can underflow.
It is possible to cause an integer overflow or underflow in the arithmetic operation.
--------------------
In file: /tmp/HelloWorld.sol:28

string memory oldMsg = message

--------------------
Initial State:

Account: [CREATOR], balance: 0x0, nonce:0, storage:{}
Account: [ATTACKER], balance: 0x0, nonce:0, storage:{}

Transaction Sequence:

-->

Expected behavior

I suppose there no problem with the Solidity code

Environment

Mythril in Docker
Mythril version v0.23.17

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

No branches or pull requests

1 participant