Skip to content

Commit

Permalink
fix: fuzzing circular bit shifts
Browse files Browse the repository at this point in the history
  • Loading branch information
FilippoTrotter authored and jaromil committed Oct 8, 2024
1 parent 8577db8 commit b458e91
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/zen_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,21 @@ int fuzz_bit_circular_shift_random(lua_State *L) {
int shift_bits = 0;

if (res->len < 256) {
shift_bits = (RAND_byte(Z->random_generator) % 256) * 8 + (RAND_byte(Z->random_generator) % 8);
shift_bits = (RAND_byte(Z->random_generator) % res->len) * 8 + (RAND_byte(Z->random_generator) % 8);
}
else if (res->len < 65535) {
uint16_t point16 =

Check warning on line 229 in src/zen_fuzzer.c

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] src/zen_fuzzer.c#L229

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
Raw output
src/zen_fuzzer.c:229:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
RAND_byte(Z->random_generator)
| (uint32_t)RAND_byte(Z->random_generator) << 8;
shift_bits = point16 % total_bits;
shift_bits = (point16 % res->len) * 8 + (RAND_byte(Z->random_generator) % 8);
}
else if (res->len < INT_MAX) {
uint32_t point32 =
RAND_byte(Z->random_generator)
| (uint32_t) RAND_byte(Z->random_generator) << 8
| (uint32_t) RAND_byte(Z->random_generator) << 16
| (uint32_t) RAND_byte(Z->random_generator) << 24;
shift_bits = point32 % total_bits;
shift_bits = (point32 % res->len) * 8 + (RAND_byte(Z->random_generator) % 8);
}

OCT_circular_shl_bits(res, shift_bits);
Expand Down

0 comments on commit b458e91

Please sign in to comment.