Omniscia SaucerSwap Labs Audit

HTSLib Manual Review Findings

HTSLib Manual Review Findings

HTS-01M: Potentially Insecure Value Negation

Description:

The value being negated in the referenced statement may be equal to type(int64).min which would result in an uncaught overflow if attempted to be negated.

Example:

src/libraries/HTSLib.sol
98function _int64ToString(int64 value) private pure returns (string memory) {
99 if (value == 0) {
100 return "0";
101 }
102
103 bool negative = value < 0;
104 uint64 temp = negative ? uint64(-value) : uint64(value);
105 uint256 digits;
106 uint64 temp2 = temp;
107
108 while (temp2 != 0) {
109 digits++;
110 temp2 /= 10;
111 }
112
113 bytes memory buffer = new bytes(digits + (negative ? 1 : 0));
114
115 if (negative) {
116 buffer[0] = "-";
117 }
118
119 uint256 index = buffer.length;
120 while (temp != 0) {
121 index--;
122 buffer[index] = bytes1(uint8(48 + temp % 10));
123 temp /= 10;
124 }
125
126 return string(buffer);
127}

Recommendation:

We advise the code to handle the special case of type(int64).min manually, yielding the value in its text format directly in such a case.

Alleviation (785446ee095db8d42f50665408df09339b4513d8):

The codebase has undergone a significant refactor rendering this exhibit no longer applicable.