@@ -1921,14 +1921,14 @@ u8 fuzz_one_original(afl_state_t *afl) {
1921
1921
1922
1922
/* Flip a single bit somewhere. Spooky! */
1923
1923
1924
- FLIP_BIT (out_buf , rand_below (afl , temp_len << 3 ));
1924
+ FLIP_BIT (out_buf , rand_below_datalen (afl , temp_len << 3 ));
1925
1925
break ;
1926
1926
1927
1927
case 1 :
1928
1928
1929
1929
/* Set byte to interesting value. */
1930
1930
1931
- out_buf [rand_below (afl , temp_len )] =
1931
+ out_buf [rand_below_datalen (afl , temp_len )] =
1932
1932
interesting_8 [rand_below (afl , sizeof (interesting_8 ))];
1933
1933
break ;
1934
1934
@@ -1940,12 +1940,12 @@ u8 fuzz_one_original(afl_state_t *afl) {
1940
1940
1941
1941
if (rand_below (afl , 2 )) {
1942
1942
1943
- * (u16 * )(out_buf + rand_below (afl , temp_len - 1 )) =
1943
+ * (u16 * )(out_buf + rand_below_datalen (afl , temp_len - 1 )) =
1944
1944
interesting_16 [rand_below (afl , sizeof (interesting_16 ) >> 1 )];
1945
1945
1946
1946
} else {
1947
1947
1948
- * (u16 * )(out_buf + rand_below (afl , temp_len - 1 )) = SWAP16 (
1948
+ * (u16 * )(out_buf + rand_below_datalen (afl , temp_len - 1 )) = SWAP16 (
1949
1949
interesting_16 [rand_below (afl , sizeof (interesting_16 ) >> 1 )]);
1950
1950
1951
1951
}
@@ -1960,12 +1960,12 @@ u8 fuzz_one_original(afl_state_t *afl) {
1960
1960
1961
1961
if (rand_below (afl , 2 )) {
1962
1962
1963
- * (u32 * )(out_buf + rand_below (afl , temp_len - 3 )) =
1963
+ * (u32 * )(out_buf + rand_below_datalen (afl , temp_len - 3 )) =
1964
1964
interesting_32 [rand_below (afl , sizeof (interesting_32 ) >> 2 )];
1965
1965
1966
1966
} else {
1967
1967
1968
- * (u32 * )(out_buf + rand_below (afl , temp_len - 3 )) = SWAP32 (
1968
+ * (u32 * )(out_buf + rand_below_datalen (afl , temp_len - 3 )) = SWAP32 (
1969
1969
interesting_32 [rand_below (afl , sizeof (interesting_32 ) >> 2 )]);
1970
1970
1971
1971
}
@@ -1976,14 +1976,16 @@ u8 fuzz_one_original(afl_state_t *afl) {
1976
1976
1977
1977
/* Randomly subtract from byte. */
1978
1978
1979
- out_buf [rand_below (afl , temp_len )] -= 1 + rand_below (afl , ARITH_MAX );
1979
+ out_buf [rand_below_datalen (afl , temp_len )] -=
1980
+ 1 + rand_below (afl , ARITH_MAX );
1980
1981
break ;
1981
1982
1982
1983
case 5 :
1983
1984
1984
1985
/* Randomly add to byte. */
1985
1986
1986
- out_buf [rand_below (afl , temp_len )] += 1 + rand_below (afl , ARITH_MAX );
1987
+ out_buf [rand_below_datalen (afl , temp_len )] +=
1988
+ 1 + rand_below (afl , ARITH_MAX );
1987
1989
break ;
1988
1990
1989
1991
case 6 :
@@ -1994,13 +1996,13 @@ u8 fuzz_one_original(afl_state_t *afl) {
1994
1996
1995
1997
if (rand_below (afl , 2 )) {
1996
1998
1997
- u32 pos = rand_below (afl , temp_len - 1 );
1999
+ u32 pos = rand_below_datalen (afl , temp_len - 1 );
1998
2000
1999
2001
* (u16 * )(out_buf + pos ) -= 1 + rand_below (afl , ARITH_MAX );
2000
2002
2001
2003
} else {
2002
2004
2003
- u32 pos = rand_below (afl , temp_len - 1 );
2005
+ u32 pos = rand_below_datalen (afl , temp_len - 1 );
2004
2006
u16 num = 1 + rand_below (afl , ARITH_MAX );
2005
2007
2006
2008
* (u16 * )(out_buf + pos ) =
@@ -2018,13 +2020,13 @@ u8 fuzz_one_original(afl_state_t *afl) {
2018
2020
2019
2021
if (rand_below (afl , 2 )) {
2020
2022
2021
- u32 pos = rand_below (afl , temp_len - 1 );
2023
+ u32 pos = rand_below_datalen (afl , temp_len - 1 );
2022
2024
2023
2025
* (u16 * )(out_buf + pos ) += 1 + rand_below (afl , ARITH_MAX );
2024
2026
2025
2027
} else {
2026
2028
2027
- u32 pos = rand_below (afl , temp_len - 1 );
2029
+ u32 pos = rand_below_datalen (afl , temp_len - 1 );
2028
2030
u16 num = 1 + rand_below (afl , ARITH_MAX );
2029
2031
2030
2032
* (u16 * )(out_buf + pos ) =
@@ -2042,13 +2044,13 @@ u8 fuzz_one_original(afl_state_t *afl) {
2042
2044
2043
2045
if (rand_below (afl , 2 )) {
2044
2046
2045
- u32 pos = rand_below (afl , temp_len - 3 );
2047
+ u32 pos = rand_below_datalen (afl , temp_len - 3 );
2046
2048
2047
2049
* (u32 * )(out_buf + pos ) -= 1 + rand_below (afl , ARITH_MAX );
2048
2050
2049
2051
} else {
2050
2052
2051
- u32 pos = rand_below (afl , temp_len - 3 );
2053
+ u32 pos = rand_below_datalen (afl , temp_len - 3 );
2052
2054
u32 num = 1 + rand_below (afl , ARITH_MAX );
2053
2055
2054
2056
* (u32 * )(out_buf + pos ) =
@@ -2066,13 +2068,13 @@ u8 fuzz_one_original(afl_state_t *afl) {
2066
2068
2067
2069
if (rand_below (afl , 2 )) {
2068
2070
2069
- u32 pos = rand_below (afl , temp_len - 3 );
2071
+ u32 pos = rand_below_datalen (afl , temp_len - 3 );
2070
2072
2071
2073
* (u32 * )(out_buf + pos ) += 1 + rand_below (afl , ARITH_MAX );
2072
2074
2073
2075
} else {
2074
2076
2075
- u32 pos = rand_below (afl , temp_len - 3 );
2077
+ u32 pos = rand_below_datalen (afl , temp_len - 3 );
2076
2078
u32 num = 1 + rand_below (afl , ARITH_MAX );
2077
2079
2078
2080
* (u32 * )(out_buf + pos ) =
@@ -2088,7 +2090,8 @@ u8 fuzz_one_original(afl_state_t *afl) {
2088
2090
why not. We use XOR with 1-255 to eliminate the
2089
2091
possibility of a no-op. */
2090
2092
2091
- out_buf [rand_below (afl , temp_len )] ^= 1 + rand_below (afl , 255 );
2093
+ out_buf [rand_below_datalen (afl , temp_len )] ^=
2094
+ 1 + rand_below (afl , 255 );
2092
2095
break ;
2093
2096
2094
2097
case 11 ... 12 : {
@@ -2105,7 +2108,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2105
2108
2106
2109
del_len = choose_block_len (afl , temp_len - 1 );
2107
2110
2108
- del_from = rand_below (afl , temp_len - del_len + 1 );
2111
+ del_from = rand_below_datalen (afl , temp_len - del_len + 1 );
2109
2112
2110
2113
memmove (out_buf + del_from , out_buf + del_from + del_len ,
2111
2114
temp_len - del_from - del_len );
@@ -2129,7 +2132,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2129
2132
if (actually_clone ) {
2130
2133
2131
2134
clone_len = choose_block_len (afl , temp_len );
2132
- clone_from = rand_below (afl , temp_len - clone_len + 1 );
2135
+ clone_from = rand_below_datalen (afl , temp_len - clone_len + 1 );
2133
2136
2134
2137
} else {
2135
2138
@@ -2138,7 +2141,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2138
2141
2139
2142
}
2140
2143
2141
- clone_to = rand_below (afl , temp_len );
2144
+ clone_to = rand_below_datalen (afl , temp_len );
2142
2145
2143
2146
new_buf =
2144
2147
ck_maybe_grow (BUF_PARAMS (out_scratch ), temp_len + clone_len );
@@ -2156,8 +2159,9 @@ u8 fuzz_one_original(afl_state_t *afl) {
2156
2159
} else {
2157
2160
2158
2161
memset (new_buf + clone_to ,
2159
- rand_below (afl , 2 ) ? rand_below (afl , 256 )
2160
- : out_buf [rand_below (afl , temp_len )],
2162
+ rand_below (afl , 2 )
2163
+ ? rand_below (afl , 256 )
2164
+ : out_buf [rand_below_datalen (afl , temp_len )],
2161
2165
clone_len );
2162
2166
2163
2167
}
@@ -2186,8 +2190,8 @@ u8 fuzz_one_original(afl_state_t *afl) {
2186
2190
2187
2191
copy_len = choose_block_len (afl , temp_len - 1 );
2188
2192
2189
- copy_from = rand_below (afl , temp_len - copy_len + 1 );
2190
- copy_to = rand_below (afl , temp_len - copy_len + 1 );
2193
+ copy_from = rand_below_datalen (afl , temp_len - copy_len + 1 );
2194
+ copy_to = rand_below_datalen (afl , temp_len - copy_len + 1 );
2191
2195
2192
2196
if (rand_below (afl , 4 )) {
2193
2197
@@ -2200,8 +2204,9 @@ u8 fuzz_one_original(afl_state_t *afl) {
2200
2204
} else {
2201
2205
2202
2206
memset (out_buf + copy_to ,
2203
- rand_below (afl , 2 ) ? rand_below (afl , 256 )
2204
- : out_buf [rand_below (afl , temp_len )],
2207
+ rand_below (afl , 2 )
2208
+ ? rand_below (afl , 256 )
2209
+ : out_buf [rand_below_datalen (afl , temp_len )],
2205
2210
copy_len );
2206
2211
2207
2212
}
@@ -2233,7 +2238,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2233
2238
2234
2239
if (extra_len > temp_len ) { break ; }
2235
2240
2236
- insert_at = rand_below (afl , temp_len - extra_len + 1 );
2241
+ insert_at = rand_below_datalen (afl , temp_len - extra_len + 1 );
2237
2242
memcpy (out_buf + insert_at , afl -> a_extras [use_extra ].data ,
2238
2243
extra_len );
2239
2244
@@ -2247,7 +2252,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2247
2252
2248
2253
if (extra_len > temp_len ) { break ; }
2249
2254
2250
- insert_at = rand_below (afl , temp_len - extra_len + 1 );
2255
+ insert_at = rand_below_datalen (afl , temp_len - extra_len + 1 );
2251
2256
memcpy (out_buf + insert_at , afl -> extras [use_extra ].data ,
2252
2257
extra_len );
2253
2258
@@ -2258,7 +2263,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2258
2263
} else { // case 16
2259
2264
2260
2265
u32 use_extra , extra_len ,
2261
- insert_at = rand_below (afl , temp_len + 1 );
2266
+ insert_at = rand_below_datalen (afl , temp_len + 1 );
2262
2267
u8 * ptr ;
2263
2268
2264
2269
/* Insert an extra. Do the same dice-rolling stuff as for the
@@ -2362,8 +2367,8 @@ u8 fuzz_one_original(afl_state_t *afl) {
2362
2367
copy_len = choose_block_len (afl , new_len - 1 );
2363
2368
if (copy_len > temp_len ) copy_len = temp_len ;
2364
2369
2365
- copy_from = rand_below (afl , new_len - copy_len + 1 );
2366
- copy_to = rand_below (afl , temp_len - copy_len + 1 );
2370
+ copy_from = rand_below_datalen (afl , new_len - copy_len + 1 );
2371
+ copy_to = rand_below_datalen (afl , temp_len - copy_len + 1 );
2367
2372
2368
2373
memmove (out_buf + copy_to , new_buf + copy_from , copy_len );
2369
2374
@@ -2372,9 +2377,9 @@ u8 fuzz_one_original(afl_state_t *afl) {
2372
2377
u32 clone_from , clone_to , clone_len ;
2373
2378
2374
2379
clone_len = choose_block_len (afl , new_len );
2375
- clone_from = rand_below (afl , new_len - clone_len + 1 );
2380
+ clone_from = rand_below_datalen (afl , new_len - clone_len + 1 );
2376
2381
2377
- clone_to = rand_below (afl , temp_len );
2382
+ clone_to = rand_below_datalen (afl , temp_len );
2378
2383
2379
2384
u8 * temp_buf =
2380
2385
ck_maybe_grow (BUF_PARAMS (out_scratch ), temp_len + clone_len );
@@ -2523,7 +2528,7 @@ u8 fuzz_one_original(afl_state_t *afl) {
2523
2528
2524
2529
/* Split somewhere between the first and last differing byte. */
2525
2530
2526
- split_at = f_diff + rand_below (afl , l_diff - f_diff );
2531
+ split_at = f_diff + rand_below_datalen (afl , l_diff - f_diff );
2527
2532
2528
2533
/* Do the thing. */
2529
2534
0 commit comments