Skip to content

Commit 33a0b64

Browse files
Remove wrong checks on negativeness of offsets in abstract memory
1 parent 1d31d94 commit 33a0b64

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

src/main/java/it/unipr/analysis/AbstractMemory.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,7 @@ public AbstractMemory mstore(StackElement offset, StackElement e) {
5555
log.warn("Offset is greater than max memory size, ignoring mstore with offset {}, value {}.", offset, e);
5656
return AbstractMemory.BOTTOM;
5757
}
58-
59-
if (offset.compareTo(StackElement.ZERO) < 0) {
60-
log.warn("Offset is negative, ignoring mstore with offset {}, value {}.", offset, e);
61-
return AbstractMemory.BOTTOM;
62-
} else if (e.compareTo(StackElement.ZERO) < 0) {
63-
log.warn("Value is negative, ignoring mstore with offset {}, value {}.", offset, e);
64-
return AbstractMemory.BOTTOM;
65-
}
66-
67-
if (offset.compareTo(new StackElement(Number.MAX_INT)) >= 0) {
68-
log.warn("Offset is greater than max int representation, ignoring mstore with offset {}, value {}.", offset, e);
69-
return AbstractMemory.BOTTOM; // fake path
70-
}
71-
58+
7259
int offsetInt = offset.getNumber().getInt();
7360

7461
if (e.isTop() || e.isTopNotJumpdest()) {
@@ -91,9 +78,6 @@ public AbstractMemory mstore8(StackElement offset, StackElement value) {
9178
if (offset.compareTo(new StackElement(MAX_MEMORY_SIZE)) >= 0) {
9279
log.warn("Offset or value are greater than max memory size, ignoring mstore8 with offset {} and value {}.", offset, value);
9380
return AbstractMemory.BOTTOM;
94-
} else if (offset.compareTo(StackElement.ZERO) < 0) {
95-
log.warn("Offset is negative, ignoring mstore8 with offset {}.", offset);
96-
return AbstractMemory.BOTTOM;
9781
}
9882

9983
int offsetInt = offset.getNumber().getInt();
@@ -112,9 +96,6 @@ public StackElement mload(StackElement offset) {
11296
if (offset.compareTo(new StackElement(MAX_MEMORY_SIZE)) >= 0) {
11397
log.warn("Offset is greater than max memory size, ignoring mload with offset {}.", offset);
11498
return StackElement.BOTTOM;
115-
} else if (offset.compareTo(StackElement.ZERO) < 0) {
116-
log.warn("Offset is negative, ignoring mload with offset {}.", offset);
117-
return StackElement.BOTTOM;
11899
} else if (offset.compareTo(new StackElement(Number.MAX_INT)) >= 0) {
119100
log.warn("Offset is greater than max int representation, ignoring mload with offset {}.", offset);
120101
return StackElement.BOTTOM; // fake path
@@ -126,27 +107,13 @@ public StackElement mload(StackElement offset) {
126107
AbstractByte[] result = new AbstractByte[WORD_SIZE];
127108
System.arraycopy(newMemory, value, result, 0, WORD_SIZE);
128109

129-
log.debug("newMemory result: {}", printBytes(newMemory));
130-
log.debug("mload result: {}", printBytes(result));
131-
132110
if (isUnknown(result))
133111
return StackElement.TOP;
134112

135113
return StackElement.fromBytes(result);
136114
}
137115

138116
public AbstractMemory mcopy(StackElement destOffset, StackElement srcOffset, StackElement length) {
139-
if (length.compareTo(StackElement.ZERO) < 0) {
140-
log.warn("Length is less than zero, ignoring mcopy with destOffset {}, srcOffset {}, length {}.", destOffset, srcOffset, length);
141-
return this;
142-
} else if (destOffset.compareTo(StackElement.ZERO) < 0) {
143-
log.warn("destOffset is negative, ignoring mcopy with destOffset {}, srcOffset {}, length {}.", destOffset, srcOffset, length);
144-
return AbstractMemory.BOTTOM;
145-
} else if (srcOffset.compareTo(StackElement.ZERO) < 0) {
146-
log.warn("srcOffset is negative, ignoring mcopy with destOffset {}, srcOffset {}, length {}.", destOffset, srcOffset, length);
147-
return AbstractMemory.BOTTOM;
148-
}
149-
150117
if (length.compareTo(new StackElement(MAX_MEMORY_SIZE)) >= 0) {
151118
log.warn("length is greater than max memory size, ignoring mcopy with destOffset {}, srcOffset {}, length {}.", destOffset, srcOffset, length);
152119
return AbstractMemory.TOP;

0 commit comments

Comments
 (0)