https://github.com/python/cpython/commit/31c41a61f1afb7929d2698e48894264d8e2df86b
commit: 31c41a61f1afb7929d2698e48894264d8e2df86b
branch: main
author: Stan Ulbrych <[email protected]>
committer: ammaraskar <[email protected]>
date: 2026-03-14T11:11:29-07:00
summary:

Fix `fuzz_builtin_int` fuzzer reproducibility (#145890)

files:
M Modules/_xxtestfuzz/fuzzer.c

diff --git a/Modules/_xxtestfuzz/fuzzer.c b/Modules/_xxtestfuzz/fuzzer.c
index 6cb11562476e40..02afb01d3731fb 100644
--- a/Modules/_xxtestfuzz/fuzzer.c
+++ b/Modules/_xxtestfuzz/fuzzer.c
@@ -38,23 +38,18 @@ static int fuzz_builtin_float(const char* data, size_t 
size) {
 static int fuzz_builtin_int(const char* data, size_t size) {
     /* Ignore test cases with very long ints to avoid timeouts
        int("9" * 1000000) is not a very interesting test caase */
-    if (size > MAX_INT_TEST_SIZE) {
+    if (size < 1 || size > MAX_INT_TEST_SIZE) {
         return 0;
     }
-    /* Pick a random valid base. (When the fuzzed function takes extra
-       parameters, it's somewhat normal to hash the input to generate those
-       parameters. We want to exercise all code paths, so we do so here.) */
-    int base = Py_HashBuffer(data, size) % 37;
+    // Use the first byte to pick a base
+    int base = ((unsigned char) data[0]) % 37;
     if (base == 1) {
         // 1 is the only number between 0 and 36 that is not a valid base.
         base = 0;
     }
-    if (base == -1) {
-        return 0;  // An error occurred, bail early.
-    }
-    if (base < 0) {
-        base = -base;
-    }
+
+    data += 1;
+    size -= 1;
 
     PyObject* s = PyUnicode_FromStringAndSize(data, size);
     if (s == NULL) {

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to