Skip to content

Commit 77a23ba

Browse files
Added an extra check before decompressing the calldata chunk
1 parent 9c136c0 commit 77a23ba

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src_features/generic_tx_parser/calldata.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ const uint8_t *calldata_get_selector(void) {
200200

201201
const uint8_t *calldata_get_chunk(int idx) {
202202
size_t offset = 0;
203+
size_t offset_after;
203204

204205
if (!has_valid_calldata(g_calldata) || (g_calldata->chunks == NULL)) {
205206
return NULL;
@@ -208,7 +209,10 @@ const uint8_t *calldata_get_chunk(int idx) {
208209
if (offset > g_calldata->chunks_size) return NULL;
209210
offset += sizeof(chunk_info_t) + CHUNK_INFO_SIZE(g_calldata->chunks[offset]);
210211
}
211-
if (!decompress_chunk(g_calldata, offset)) return NULL;
212+
offset_after = offset + sizeof(chunk_info_t) + CHUNK_INFO_SIZE(g_calldata->chunks[offset]);
213+
if ((offset_after > g_calldata->chunks_size) || !decompress_chunk(g_calldata, offset)) {
214+
return NULL;
215+
}
212216
return g_calldata->chunk;
213217
}
214218

0 commit comments

Comments
 (0)