Ignore:
Timestamp:
Jan 27, 2007, 8:05:46 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • Implemented -f/--fuzzing (fuzzing mode).
File:
1 edited

Legend:

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

    r1719 r1720  
    3737#define MAGIC2 0x783bc31f
    3838
     39/* Fuzzing mode */
     40static enum fuzzing
     41{
     42    FUZZING_XOR = 0, FUZZING_SET, FUZZING_UNSET
     43}
     44fuzzing;
     45
    3946/* Per-offset byte protection */
    4047static unsigned int *ranges = NULL;
     
    4754/* Local prototypes */
    4855static void readchars(int *, char const *);
     56
     57extern void _zz_fuzzing(char const *mode)
     58{
     59    if(!strcmp(mode, "xor"))
     60        fuzzing = FUZZING_XOR;
     61    else if(!strcmp(mode, "set"))
     62        fuzzing = FUZZING_SET;
     63    else if(!strcmp(mode, "unset"))
     64        fuzzing = FUZZING_UNSET;
     65}
    4966
    5067void _zz_bytes(char const *list)
     
    144161        {
    145162            unsigned int *r;
    146             uint8_t byte;
     163            uint8_t byte, fuzzbyte;
    147164
    148165            if(!ranges)
     
    161178                continue;
    162179
    163             byte ^= fuzz->data[j % CHUNKBYTES];
     180            fuzzbyte = fuzz->data[j % CHUNKBYTES];
     181
     182            if(!fuzzbyte)
     183                continue;
     184
     185            switch(fuzzing)
     186            {
     187            case FUZZING_XOR:
     188                byte ^= fuzzbyte;
     189                break;
     190            case FUZZING_SET:
     191                byte |= fuzzbyte;
     192                break;
     193            case FUZZING_UNSET:
     194                byte &= ~fuzzbyte;
     195                break;
     196            }
    164197
    165198            if(refuse[byte])
Note: See TracChangeset for help on using the changeset viewer.