jt2594838 commented on code in PR #18693:
URL: https://github.com/apache/iotdb/pull/18693#discussion_r4078641465


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALMetaData.java:
##########
@@ -218,9 +222,17 @@ public static WALMetaData deserialize(ByteBuffer buffer) {
   public static WALMetaData deserialize(ByteBuffer buffer, WALFileVersion 
version) {
     long firstSearchIndex = buffer.getLong();
     int entriesNum = buffer.getInt();
+    // Reject corrupted counts before allocating arrays from an untrusted 
footer.
+    if (entriesNum < 0 || entriesNum > buffer.remaining() / Integer.BYTES) {
+      throw new 
IllegalArgumentException(StorageEngineMessages.UNEXPECTED_EXCEPTION);
+    }
     List<Integer> buffersSize = new ArrayList<>(entriesNum);
     for (int i = 0; i < entriesNum; ++i) {
-      buffersSize.add(buffer.getInt());
+      int size = buffer.getInt();
+      if (size <= 0) {

Review Comment:
   Currently, we only perform a best-effort recovery without affecting the 
normal path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to