Changeset 1483
- Timestamp:
- 12/15/06 15:07:46 (6 years ago)
- File:
-
- 1 edited
-
zzuf/trunk/src/fuzz.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/fuzz.c
r1481 r1483 38 38 { 39 39 uint8_t bits[CHUNK_SIZE]; 40 uint64_t pos , offset;40 uint64_t pos; 41 41 unsigned int i; 42 42 43 43 pos = files[fd].pos; 44 offset = pos % CHUNK_SIZE;45 44 46 for(i = pos / CHUNK_SIZE; i < (pos + len) / CHUNK_SIZE + 1; i++) 45 for(i = pos / CHUNK_SIZE; 46 i < (pos + len + CHUNK_SIZE - 1) / CHUNK_SIZE; 47 i++) 47 48 { 48 49 int todo; 49 50 50 51 /* Add some random dithering to handle percent < 1.0/CHUNK_SIZE */ 51 zzuf_srand(_zzuf_seed ^ (i * 0x 23ea84f7));52 zzuf_srand(_zzuf_seed ^ (i * 0x33ea84f7)); 52 53 todo = (int)((_zzuf_percent * CHUNK_SIZE + zzuf_rand(100)) / 100.0); 53 zzuf_srand(_zzuf_seed ^ (i * 0x 23ea84f7) ^ (todo * 0x783bc31f));54 zzuf_srand(_zzuf_seed ^ (i * 0x7f48ae33) ^ (todo * 0x783bc31f)); 54 55 55 56 memset(bits, 0, CHUNK_SIZE); 56 57 while(todo--) 57 58 { 58 int idx =zzuf_rand(CHUNK_SIZE);59 uint64_t idx = i * CHUNK_SIZE + zzuf_rand(CHUNK_SIZE); 59 60 uint8_t byte = (1 << zzuf_rand(8)); 60 61 61 if(i * CHUNK_SIZE + idx < pos)62 if(idx < pos || idx >= pos + len) 62 63 continue; 63 64 64 if(i * CHUNK_SIZE + idx >= pos + len) 65 continue; 66 67 buf[idx - offset] ^= byte; 65 buf[idx - pos] ^= byte; 68 66 } 69 67 }
Note: See TracChangeset
for help on using the changeset viewer.
