You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/10/27 15:33:15 UTC

(incubator-opendal) 11/14: Fix fuzzer

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch lazy-reader
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit d690f4dbf07710389d12e5b4c2f5acd2fbef5867
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Fri Oct 27 21:52:35 2023 +0800

    Fix fuzzer
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 core/fuzz/fuzz_reader.rs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/core/fuzz/fuzz_reader.rs b/core/fuzz/fuzz_reader.rs
index d57a649a4..11c399c38 100644
--- a/core/fuzz/fuzz_reader.rs
+++ b/core/fuzz/fuzz_reader.rs
@@ -182,6 +182,16 @@ impl ReadChecker {
                 0,
                 "check read failed: output must be empty if buf_size is 0"
             );
+            return;
+        }
+
+        if self.cur >= self.ranged_data.len() {
+            assert_eq!(
+                output.len(),
+                0,
+                "check read failed: cur outsides of ranged_data, output must be empty"
+            );
+            return;
         }
 
         if buf_size > 0 && output.len() == 0 {
@@ -189,6 +199,7 @@ impl ReadChecker {
                 self.cur >= self.ranged_data.len(),
                 "check read failed: no data read means cur must outsides of ranged_data",
             );
+            return;
         }
 
         let expected = &self.ranged_data[self.cur..self.cur + output.len()];