Changeset 1672 for zzuf/trunk/src/zzuf.c
- Timestamp:
- Jan 15, 2007, 12:41:03 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/zzuf.c
r1671 r1672 74 74 int fd[3]; /* 0 is debug, 1 is stderr, 2 is stdout */ 75 75 int bytes, seed; 76 double ratio; 76 77 int64_t date; 77 78 struct md5 *ctx; … … 83 84 static uint32_t seed = DEFAULT_SEED; 84 85 static uint32_t endseed = DEFAULT_SEED + 1; 85 static double ratio = DEFAULT_RATIO;86 static double endratio = DEFAULT_RATIO;86 static double minratio = DEFAULT_RATIO; 87 static double maxratio = DEFAULT_RATIO; 87 88 static int quiet = 0; 88 89 static int maxbytes = -1; … … 218 219 case 'r': /* --ratio */ 219 220 parser = strchr(optarg, ':'); 220 ratio = atof(optarg);221 endratio = parser ? atof(parser + 1) :ratio;221 minratio = atof(optarg); 222 maxratio = parser ? atof(parser + 1) : minratio; 222 223 break; 223 224 case 'R': /* --refuse */ … … 258 259 #endif 259 260 261 _zz_setratio(minratio, maxratio); 262 _zz_setseed(seed); 263 260 264 /* If asked to read from the standard input */ 261 265 if(optind >= argc) … … 268 272 return EXIT_FAILURE; 269 273 } 270 271 _zz_setseed(seed);272 _zz_setratio(ratio);273 274 274 275 loop_stdin(); … … 381 382 { 382 383 _zz_md5_fini(md5sum, ctx); 383 fprintf(stderr, "zzuf[s eed=%i]: %.02x%.02x%.02x%.02x%.02x%.02x"384 "%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x \n",385 seed, m d5sum[0], md5sum[1], md5sum[2], md5sum[3],384 fprintf(stderr, "zzuf[s=%i,r=%g]: %.02x%.02x%.02x%.02x%.02x" 385 "%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x\n", 386 seed, minratio, md5sum[0], md5sum[1], md5sum[2], md5sum[3], 386 387 md5sum[4], md5sum[5], md5sum[6], md5sum[7], 387 388 md5sum[8], md5sum[9], md5sum[10], md5sum[11], … … 507 508 sprintf(buf, "%i", seed); 508 509 setenv("ZZUF_SEED", buf, 1); 509 sprintf(buf, "%g", ratio); 510 setenv("ZZUF_RATIO", buf, 1); 510 sprintf(buf, "%g", minratio); 511 setenv("ZZUF_MINRATIO", buf, 1); 512 sprintf(buf, "%g", maxratio); 513 setenv("ZZUF_MAXRATIO", buf, 1); 511 514 512 515 /* Run our process */ … … 519 522 } 520 523 521 if(verbose)522 fprintf(stderr, "zzuf[seed=%i]: launched %s\n", seed, newargv[0]);523 524 524 /* We’re the parent, acknowledge spawn */ 525 525 child_list[i].date = now; … … 532 532 child_list[i].bytes = 0; 533 533 child_list[i].seed = seed; 534 child_list[i].ratio = _zz_getratio(); 534 535 child_list[i].status = STATUS_RUNNING; 535 536 if(md5) 536 537 child_list[i].ctx = _zz_md5_init(); 537 538 539 if(verbose) 540 fprintf(stderr, "zzuf[s=%i,r=%g]: launched %s\n", 541 child_list[i].seed, child_list[i].ratio, newargv[0]); 542 538 543 lastlaunch = now; 539 544 child_count++; 540 545 seed++; 546 547 _zz_setseed(seed); 541 548 } 542 549 … … 553 560 { 554 561 if(verbose) 555 fprintf(stderr, "zzuf[seed=%i]: data output exceeded," 556 " sending SIGTERM\n", child_list[i].seed); 562 fprintf(stderr, "zzuf[s=%i,r=%g]: " 563 "data output exceeded, sending SIGTERM\n", 564 child_list[i].seed, child_list[i].ratio); 557 565 kill(child_list[i].pid, SIGTERM); 558 566 child_list[i].date = now; … … 565 573 { 566 574 if(verbose) 567 fprintf(stderr, "zzuf[seed=%i]: running time exceeded," 568 " sending SIGTERM\n", child_list[i].seed); 575 fprintf(stderr, "zzuf[s=%i,r=%g]: " 576 "running time exceeded, sending SIGTERM\n", 577 child_list[i].seed, child_list[i].ratio); 569 578 kill(child_list[i].pid, SIGTERM); 570 579 child_list[i].date = now; … … 580 589 { 581 590 if(verbose) 582 fprintf(stderr, "zzuf[seed=%i]: not responding," 583 " sending SIGKILL\n", child_list[i].seed); 591 fprintf(stderr, "zzuf[s=%i,r=%g]: " 592 "not responding, sending SIGKILL\n", 593 child_list[i].seed, child_list[i].ratio); 584 594 kill(child_list[i].pid, SIGKILL); 585 595 child_list[i].status = STATUS_SIGKILL; … … 605 615 if(checkexit && WIFEXITED(status) && WEXITSTATUS(status)) 606 616 { 607 fprintf(stderr, "zzuf[seed=%i]: exit %i\n", 608 child_list[i].seed, WEXITSTATUS(status)); 617 fprintf(stderr, "zzuf[s=%i,r=%g]: exit %i\n", 618 child_list[i].seed, child_list[i].ratio, 619 WEXITSTATUS(status)); 609 620 crashes++; 610 621 } … … 613 624 && child_list[i].status == STATUS_SIGTERM)) 614 625 { 615 fprintf(stderr, "zzuf[s eed=%i]: signal %i%s%s\n",616 child_list[i].seed, WTERMSIG(status),617 sig2str(WTERMSIG(status)),626 fprintf(stderr, "zzuf[s=%i,r=%g]: signal %i%s%s\n", 627 child_list[i].seed, child_list[i].ratio, 628 WTERMSIG(status), sig2str(WTERMSIG(status)), 618 629 (WTERMSIG(status) == SIGKILL && maxmem >= 0) ? 619 630 " (memory exceeded?)" : ""); … … 628 639 { 629 640 _zz_md5_fini(md5sum, child_list[i].ctx); 630 fprintf(stderr, "zzuf[s eed=%i]: %.02x%.02x%.02x%.02x%.02x%.02x"631 "%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x \n",632 child_list[i].seed, md5sum[0], md5sum[1], md5sum[2],633 md5sum[ 3], md5sum[4], md5sum[5], md5sum[6], md5sum[7],634 md5sum[ 8], md5sum[9], md5sum[10], md5sum[11], md5sum[12],635 md5sum[1 3], md5sum[14], md5sum[15]);641 fprintf(stderr, "zzuf[s=%i,r=%g]: %.02x%.02x%.02x%.02x%.02x" 642 "%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x%.02x\n", 643 child_list[i].seed, child_list[i].ratio, md5sum[0], 644 md5sum[1], md5sum[2], md5sum[3], md5sum[4], md5sum[5], 645 md5sum[6], md5sum[7], md5sum[8], md5sum[9], md5sum[10], 646 md5sum[11], md5sum[12], md5sum[13], md5sum[14], md5sum[15]); 636 647 } 637 648 child_list[i].status = STATUS_FREE; … … 795 806 printf("Mandatory arguments to long options are mandatory for short options too.\n"); 796 807 # ifdef HAVE_GETOPT_LONG 797 printf(" -A, --autoinc increment seed each time a new file is opened\n"); 798 printf(" -B, --max-bytes <n> kill children that output more than <n> bytes\n"); 799 printf(" -c, --cmdline only fuzz files specified in the command line\n"); 800 printf(" -C, --max-crashes <n> stop after <n> children have crashed (default 1)\n"); 801 printf(" -d, --debug print debug messages\n"); 802 printf(" -D, --delay delay between forks\n"); 803 printf(" -E, --exclude <regex> do not fuzz files matching <regex>\n"); 804 printf(" -F, --max-forks <n> number of concurrent children (default 1)\n"); 805 printf(" -i, --stdin fuzz standard input\n"); 806 printf(" -I, --include <regex> only fuzz files matching <regex>\n"); 807 printf(" -m, --md5 compute the output's MD5 hash\n"); 808 printf(" -M, --max-memory <n> maximum child virtual memory size in MB\n"); 809 printf(" -n, --network fuzz network input\n"); 810 printf(" -P, --protect <list> protect bytes and characters in <list>\n"); 811 printf(" -q, --quiet do not print children's messages\n"); 812 printf(" -r, --ratio <ratio> bit fuzzing ratio (default 0.004)\n"); 813 printf(" -R, --refuse <list> refuse bytes and characters in <list>\n"); 814 printf(" -s, --seed <seed> random seed (default 0)\n"); 815 printf(" --seed <start:stop> specify a seed range\n"); 816 printf(" -S, --signal prevent children from diverting crashing signals\n"); 817 printf(" -T, --max-time <n> kill children that run for more than <n> seconds\n"); 818 printf(" -v, --verbose print information during the run\n"); 819 printf(" -x, --check-exit report processes that exit with a non-zero status\n"); 820 printf(" -h, --help display this help and exit\n"); 821 printf(" -V, --version output version information and exit\n"); 808 printf(" -A, --autoinc increment seed each time a new file is opened\n"); 809 printf(" -B, --max-bytes <n> kill children that output more than <n> bytes\n"); 810 printf(" -c, --cmdline only fuzz files specified in the command line\n"); 811 printf(" -C, --max-crashes <n> stop after <n> children have crashed (default 1)\n"); 812 printf(" -d, --debug print debug messages\n"); 813 printf(" -D, --delay delay between forks\n"); 814 printf(" -E, --exclude <regex> do not fuzz files matching <regex>\n"); 815 printf(" -F, --max-forks <n> number of concurrent children (default 1)\n"); 816 printf(" -i, --stdin fuzz standard input\n"); 817 printf(" -I, --include <regex> only fuzz files matching <regex>\n"); 818 printf(" -m, --md5 compute the output's MD5 hash\n"); 819 printf(" -M, --max-memory <n> maximum child virtual memory size in MB\n"); 820 printf(" -n, --network fuzz network input\n"); 821 printf(" -P, --protect <list> protect bytes and characters in <list>\n"); 822 printf(" -q, --quiet do not print children's messages\n"); 823 printf(" -r, --ratio <ratio> bit fuzzing ratio (default %g)\n", DEFAULT_RATIO); 824 printf(" --ratio <start:stop> specify a ratio range\n"); 825 printf(" -R, --refuse <list> refuse bytes and characters in <list>\n"); 826 printf(" -s, --seed <seed> random seed (default %i)\n", DEFAULT_SEED); 827 printf(" --seed <start:stop> specify a seed range\n"); 828 printf(" -S, --signal prevent children from diverting crashing signals\n"); 829 printf(" -T, --max-time <n> kill children that run for more than <n> seconds\n"); 830 printf(" -v, --verbose print information during the run\n"); 831 printf(" -x, --check-exit report processes that exit with a non-zero status\n"); 832 printf(" -h, --help display this help and exit\n"); 833 printf(" -V, --version output version information and exit\n"); 822 834 # else 823 835 printf(" -A increment seed each time a new file is opened\n"); … … 836 848 printf(" -P <list> protect bytes and characters in <list>\n"); 837 849 printf(" -q do not print the fuzzed application's messages\n"); 838 printf(" -r <ratio> bit fuzzing ratio (default 0.004)\n"); 850 printf(" -r <ratio> bit fuzzing ratio (default %g)\n", DEFAULT_RATIO); 851 printf(" <start:stop> specify a ratio range\n"); 839 852 printf(" -R <list> refuse bytes and characters in <list>\n"); 840 printf(" -s <seed> random seed (default 0)\n");853 printf(" -s <seed> random seed (default %i)\n", DEFAULT_SEED); 841 854 printf(" <start:stop> specify a seed range\n"); 842 855 printf(" -S prevent children from diverting crashing signals\n");
Note: See TracChangeset
for help on using the changeset viewer.