Changeset 1526


Ignore:
Timestamp:
Dec 29, 2006, 6:22:11 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Added the -i flag (for stdin fuzzing).
Location:
zzuf/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/doc/zzuf.1

    r1525 r1526  
    55.B zzuf
    66[
    7 .B \-vqdh
     7.B \-vqdhi
    88] [
    99.B \-r
     
    112112is very verbose but only its exit code is really useful to you.
    113113.TP
     114.B \-i, \-\-stdin
     115Fuzz the application's standard input. By default
     116.B zzuf
     117only fuzzes files.
     118.TP
    114119.B \-I, \-\-include <regex>
    115120Only fuzz files whose name matches the
  • zzuf/trunk/src/libzzuf.c

    r1524 r1526  
    8383    _zz_fd_init();
    8484
     85    tmp = getenv("ZZUF_STDIN");
     86    if(tmp && *tmp == '1')
     87        _zz_register(0);
     88
    8589    _zz_load_fd();
    8690    _zz_load_stream();
  • zzuf/trunk/src/zzuf.c

    r1525 r1526  
    9898            { "include",   1, NULL, 'I' },
    9999            { "exclude",   1, NULL, 'E' },
     100            { "stdin",     0, NULL, 'i' },
    100101            { "seed",      1, NULL, 's' },
    101102            { "ratio",     1, NULL, 'r' },
     
    108109            { "version",   0, NULL, 'v' },
    109110        };
    110         int c = getopt_long(argc, argv, "I:E:s:r:F:B:T:qdhv",
     111        int c = getopt_long(argc, argv, "I:E:is:r:F:B:T:qdhv",
    111112                            long_options, &option_index);
    112113#   else
    113114#       define MOREINFO "Try `%s -h' for more information.\n"
    114         int c = getopt(argc, argv, "I:E:s:r:F:B:T:qdhv");
     115        int c = getopt(argc, argv, "I:E:is:r:F:B:T:qdhv");
    115116#   endif
    116117        if(c == -1)
     
    124125        case 'E': /* --exclude */
    125126            setenv("ZZUF_EXCLUDE", optarg, 1);
     127            break;
     128        case 'i': /* --stdin */
     129            setenv("ZZUF_STDIN", "1", 1);
    126130            break;
    127131        case 's': /* --seed */
     
    426430static void usage(void)
    427431{
    428     printf("Usage: zzuf [ -vqdh ] [ -r ratio ] [ -s seed | -s start:stop]\n");
    429     printf("                      [ -F children ] [ -B bytes ] [ -T seconds ]\n");
    430     printf("                      [ -I include ] [ -E exclude ] COMMAND [ARGS]...\n");
    431     printf("Run COMMAND and randomly fuzz its input files.\n");
     432    printf("Usage: zzuf [ -vqdhi ] [ -r ratio ] [ -s seed | -s start:stop]\n");
     433    printf("                       [ -F children ] [ -B bytes ] [ -T seconds ]\n");
     434    printf("                       [ -I include ] [ -E exclude ] COMMAND [ARGS]...\n");
     435    printf("Run COMMAND and randomly fuzz its input.\n");
    432436    printf("\n");
    433437    printf("Mandatory arguments to long options are mandatory for short options too.\n");
     
    440444    printf("  -T, --max-time <n>       kill children that run for more than <n> seconds\n");
    441445    printf("  -q, --quiet              do not print children's messages\n");
     446    printf("  -i, --stdin              fuzz standard input\n");
    442447    printf("  -I, --include <regex>    only fuzz files matching <regex>\n");
    443448    printf("  -E, --exclude <regex>    do not fuzz files matching <regex>\n");
     
    453458    printf("  -T <n>           kill children that run for more than <n> seconds\n");
    454459    printf("  -q               do not print the fuzzed application's messages\n");
     460    printf("  -i               fuzz standard input\n");
    455461    printf("  -I <regex>       only fuzz files matching <regex>\n");
    456462    printf("  -E <regex>       do not fuzz files matching <regex>\n");
  • zzuf/trunk/test/testsuite.sh

    r1521 r1526  
    3535        rm -f /tmp/zzuf-random-$$
    3636        rm -f /tmp/zzuf-text-$$
     37        echo "Temporary files removed."
     38    else
     39        echo "Files preserved:"
     40        echo "  /tmp/zzuf-zero-$$"
     41        echo "  /tmp/zzuf-random-$$"
     42        echo "  /tmp/zzuf-text-$$"
    3743    fi
    3844}
    3945
    40 trap "echo ''; echo 'Aborted.'; cleanup; exit 0" 1 2 15
     46trap "echo ''; echo ''; echo 'Aborted.'; cleanup; exit 0" 1 2 15
    4147
    4248seed=$(($RANDOM * $$))
     
    5359
    5460for file in /tmp/zzuf-text-$$ /tmp/zzuf-zero-$$ /tmp/zzuf-random-$$; do
    55     for r in 0.0 0.00001 0.0001 0.001 0.01 0.1 1.0 10.0; do
     61    for r in 0.000000 0.00001 0.0001 0.001 0.01 0.1 1.0 10.0; do
    5662        echo "Testing zzuf on $file, ratio $r:"
    5763        OK=1
    5864        MD5=""
    5965        check $seed $r "cat $file" "cat"
    60 # don't do grep, it adds a newline at EOF!
    61 #        check $seed $r "grep -- -a \\'\\' $file" "grep -a"
     66        check $seed $r "cat < $file" "cat stdin"
     67        # We don't include grep in the testsuite because it puts a newline
     68        # at the end of its input if it was not there initially.
     69        #check $seed $r "grep -- -a \\'\\' $file" "grep -a"
    6270        check $seed $r "sed n $file" "sed n"
    6371        check $seed $r "dd bs=65536 if=$file" "dd(bs=65536)"
     
    7583    done
    7684done
    77 cleanup
    7885
    7986if [ "$FAILED" != 0 ]; then
    80     echo "$FAILED tests failed out of $TESTED. Files preserved:"
    81     echo "  /tmp/zzuf-zero-$$"
    82     echo "  /tmp/zzuf-random-$$"
    83     echo "  /tmp/zzuf-text-$$"
     87    echo "$FAILED tests failed out of $TESTED."
     88    cleanup
    8489    exit 1
    8590fi
    8691echo "All $TESTED tests OK."
     92
     93cleanup
    8794exit 0
    8895
Note: See TracChangeset for help on using the changeset viewer.