From 24fcb62a7f332f859e98e1e80d39770747f66792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammed=20Tanr=C4=B1kulu?= Date: Fri, 15 Nov 2024 20:33:17 +0100 Subject: [PATCH] update for loops in readTXT method --- contracts/dnsregistrar/OffchainDNSResolver.sol | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/contracts/dnsregistrar/OffchainDNSResolver.sol b/contracts/dnsregistrar/OffchainDNSResolver.sol index 98f8d51b..5c7e5bbc 100644 --- a/contracts/dnsregistrar/OffchainDNSResolver.sol +++ b/contracts/dnsregistrar/OffchainDNSResolver.sol @@ -201,17 +201,21 @@ contract OffchainDNSResolver is IExtendedResolver, IERC165 { uint256 lastIdx ) internal pure returns (bytes memory) { uint256 totalLength = 0; - for (uint256 idx = startidx; idx < lastIdx; idx += fieldLength + 1) { - uint256 fieldLength = data.readUint8(idx); + + for (uint256 i = startIdx; i < lastIdx; ) { + uint256 fieldLength = data.readUint8(i); totalLength += fieldLength; + i += fieldLength + 1; } bytes memory result = new bytes(totalLength); uint256 resultIdx = 0; - for (uint256 idx = startIdx; idx < lastIdx; idx += fieldLength + 1) { - uint256 fieldLength = data.readUint8(idx); - result.strcpy(resultIdx, data, idx + 1, fieldLength); + + for (uint256 i = startIdx; i < lastIdx; ) { + uint256 fieldLength = data.readUint8(i); + result.strcpy(resultIdx, data, i + 1, fieldLength); resultIdx += fieldLength; + i += fieldLength + 1; } return result; }