]> git.kaiwu.me - quickjs.git/commitdiff
Define lre_check_timeout in fuzz_regexp
authorRenata Hodovan <reni@inf.u-szeged.hu>
Thu, 10 Apr 2025 21:09:15 +0000 (23:09 +0200)
committerRenata Hodovan <reni@inf.u-szeged.hu>
Mon, 14 Apr 2025 13:56:15 +0000 (15:56 +0200)
Since #25aaa77, lre_check_timeout must be defined by the user. The
patch adds this definition to the regexp fuzzer.

fuzz/fuzz_regexp.c

index 29d195120fc9831723393a2e5c74ab65e9faf7ca..ae929e840905b07c0c5bce7459c3fef780f55d46 100644 (file)
@@ -16,6 +16,7 @@
 #include "libregexp.h"
 #include "quickjs-libc.h"
 
+static int nbinterrupts = 0;
 
 int lre_check_stack_overflow(void *opaque, size_t alloca_size) { return 0; }
 
@@ -24,6 +25,12 @@ void *lre_realloc(void *opaque, void *ptr, size_t size)
     return realloc(ptr, size);
 }
 
+int lre_check_timeout(void *opaque)
+ {
+    nbinterrupts++;
+    return (nbinterrupts > 100);
+ }
+
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     int len, ret, i;
     uint8_t *bc;