Skip to content

Commit aea2bef

Browse files
author
Micah Scott
committed
Adjust type for fuzzer random inputs
1 parent e93b66c commit aea2bef

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/libbson/tests/test-bson-vector.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,9 @@ test_bson_vector_view_api_fuzz_int8 (void)
972972
int8_t *expected_elements = bson_malloc (MAX_TESTED_VECTOR_LENGTH * sizeof *expected_elements);
973973
int8_t *actual_elements = bson_malloc (MAX_TESTED_VECTOR_LENGTH * sizeof *actual_elements);
974974
for (int fuzz_iter = 0; fuzz_iter < FUZZ_TEST_ITERS; fuzz_iter++) {
975-
int r = rand ();
976-
int r_operation = r & 0xF;
977-
int r_param = r >> 4;
975+
unsigned r = (unsigned) rand ();
976+
unsigned r_operation = r & 0xFu;
977+
size_t r_param = r >> 4;
978978

979979
if (current_length == 0 || r_operation == 15) {
980980
// Resize and fill
@@ -1028,9 +1028,9 @@ test_bson_vector_view_api_fuzz_float32 (void)
10281028
float *expected_elements = bson_malloc (MAX_TESTED_VECTOR_LENGTH * sizeof *expected_elements);
10291029
float *actual_elements = bson_malloc (MAX_TESTED_VECTOR_LENGTH * sizeof *actual_elements);
10301030
for (int fuzz_iter = 0; fuzz_iter < FUZZ_TEST_ITERS; fuzz_iter++) {
1031-
int r = rand ();
1032-
int r_operation = r & 0xF;
1033-
int r_param = r >> 4;
1031+
unsigned r = (unsigned) rand ();
1032+
unsigned r_operation = r & 0xFu;
1033+
size_t r_param = r >> 4;
10341034

10351035
if (current_length == 0 || r_operation == 15) {
10361036
// Resize and fill
@@ -1085,9 +1085,9 @@ test_bson_vector_view_api_fuzz_packed_bit (void)
10851085
bool *actual_elements = bson_malloc (MAX_TESTED_VECTOR_LENGTH * sizeof *actual_elements);
10861086
uint8_t *packed_buffer = bson_malloc ((MAX_TESTED_VECTOR_LENGTH + 7) / 8);
10871087
for (int fuzz_iter = 0; fuzz_iter < FUZZ_TEST_ITERS; fuzz_iter++) {
1088-
int r = rand ();
1089-
int r_operation = r & 0xF;
1090-
int r_param = r >> 4;
1088+
unsigned r = (unsigned) rand ();
1089+
unsigned r_operation = r & 0xFu;
1090+
size_t r_param = r >> 4;
10911091

10921092
if (current_length == 0 || r_operation == 15) {
10931093
// Resize and fill from unpacked bool source

0 commit comments

Comments
 (0)