gh-122854: Add Py_HashBuffer() function (#122855)

This commit is contained in:
Victor Stinner 2024-08-30 17:42:27 +02:00 committed by GitHub
parent 3d60dfbe17
commit d8e69b2c1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 80 additions and 25 deletions

View file

@ -15,7 +15,6 @@
#endif
#include <Python.h>
#include "pycore_pyhash.h" // _Py_HashBytes()
#include <stdlib.h>
#include <inttypes.h>
@ -45,7 +44,7 @@ static int fuzz_builtin_int(const char* data, size_t size) {
/* 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_HashBytes(data, size) % 37;
int base = Py_HashBuffer(data, size) % 37;
if (base == 1) {
// 1 is the only number between 0 and 36 that is not a valid base.
base = 0;