Changeset 1483


Ignore:
Timestamp:
12/15/06 15:07:46 (6 years ago)
Author:
sam
Message:
  • Really fix the inconsistency bug. Now dd bs=2048 count=1 gives the same result as dd bs=1 count=2048.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/fuzz.c

    r1481 r1483  
    3838{ 
    3939    uint8_t bits[CHUNK_SIZE]; 
    40     uint64_t pos, offset; 
     40    uint64_t pos; 
    4141    unsigned int i; 
    4242 
    4343    pos = files[fd].pos; 
    44     offset = pos % CHUNK_SIZE; 
    4544 
    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++) 
    4748    { 
    4849        int todo; 
    4950 
    5051        /* Add some random dithering to handle percent < 1.0/CHUNK_SIZE */ 
    51         zzuf_srand(_zzuf_seed ^ (i * 0x23ea84f7)); 
     52        zzuf_srand(_zzuf_seed ^ (i * 0x33ea84f7)); 
    5253        todo = (int)((_zzuf_percent * CHUNK_SIZE + zzuf_rand(100)) / 100.0); 
    53         zzuf_srand(_zzuf_seed ^ (i * 0x23ea84f7) ^ (todo * 0x783bc31f)); 
     54        zzuf_srand(_zzuf_seed ^ (i * 0x7f48ae33) ^ (todo * 0x783bc31f)); 
    5455 
    5556        memset(bits, 0, CHUNK_SIZE); 
    5657        while(todo--) 
    5758        { 
    58             int idx = zzuf_rand(CHUNK_SIZE); 
     59            uint64_t idx = i * CHUNK_SIZE + zzuf_rand(CHUNK_SIZE); 
    5960            uint8_t byte = (1 << zzuf_rand(8)); 
    6061 
    61             if(i * CHUNK_SIZE + idx < pos) 
     62            if(idx < pos || idx >= pos + len) 
    6263                continue; 
    6364 
    64             if(i * CHUNK_SIZE + idx >= pos + len) 
    65                 continue; 
    66  
    67             buf[idx - offset] ^= byte; 
     65            buf[idx - pos] ^= byte; 
    6866        } 
    6967    } 
Note: See TracChangeset for help on using the changeset viewer.