Changeset 1641 for zzuf/trunk/src/zzuf.c
- Timestamp:
- Jan 10, 2007, 6:17:26 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/zzuf.c
r1640 r1641 37 37 #include <time.h> 38 38 #include <sys/wait.h> 39 #include <sys/time.h> 40 #include <sys/resource.h> 39 41 40 42 #include "libzzuf.h" … … 81 83 static int md5 = 0; 82 84 static int checkexit = 0; 85 static int maxmem = -1; 83 86 static double maxtime = -1.0; 84 87 … … 120 123 { "include", 1, NULL, 'I' }, 121 124 { "md5", 0, NULL, 'm' }, 125 { "max-memory", 1, NULL, 'M' }, 122 126 { "network", 0, NULL, 'n' }, 123 127 { "protect", 1, NULL, 'P' }, … … 132 136 { "version", 0, NULL, 'v' }, 133 137 }; 134 int c = getopt_long(argc, argv, "B:cC:dE:F:iI:m nP:qr:R:s:ST:xhv",138 int c = getopt_long(argc, argv, "B:cC:dE:F:iI:mM:nP:qr:R:s:ST:xhv", 135 139 long_options, &option_index); 136 140 # else 137 141 # define MOREINFO "Try `%s -h' for more information.\n" 138 int c = getopt(argc, argv, "B:cC:dE:F:iI:m nP:qr:R:s:ST:xhv");142 int c = getopt(argc, argv, "B:cC:dE:F:iI:mM:nP:qr:R:s:ST:xhv"); 139 143 # endif 140 144 if(c == -1) … … 181 185 case 'm': /* --md5 */ 182 186 md5 = 1; 187 break; 188 case 'M': /* --max-memory */ 189 setenv("ZZUF_MEMORY", "1", 1); 190 maxmem = atoi(optarg); 183 191 break; 184 192 case 'n': /* --network */ … … 425 433 case 0: 426 434 /* We’re the child */ 435 if(maxmem >= 0) 436 { 437 struct rlimit rlim; 438 rlim.rlim_cur = maxmem * 1000000; 439 rlim.rlim_max = maxmem * 1000000; 440 setrlimit(RLIMIT_AS, &rlim); 441 } 442 427 443 for(j = 0; j < 3; j++) 428 444 { … … 529 545 else if(WIFSIGNALED(status)) 530 546 { 531 fprintf(stdout, "zzuf[seed=%i]: signal %i\n", 532 child_list[i].seed, WTERMSIG(status)); 547 fprintf(stdout, "zzuf[seed=%i]: signal %i%s\n", 548 child_list[i].seed, WTERMSIG(status), 549 (WTERMSIG(status) == SIGKILL && maxmem >= 0) ? 550 " (memory exceeded?)" : ""); 533 551 crashes++; 534 552 } … … 667 685 printf("Usage: zzuf [-cdimnqSx] [-r ratio] [-s seed | -s start:stop]\n"); 668 686 printf(" [-F forks] [-C crashes] [-B bytes] [-T seconds]\n"); 669 printf(" [- P protect] [-R refuse]\n");687 printf(" [-M bytes] [-P protect] [-R refuse]\n"); 670 688 printf(" [-I include] [-E exclude] [PROGRAM [ARGS]...]\n"); 671 689 # ifdef HAVE_GETOPT_LONG … … 689 707 printf(" -I, --include <regex> only fuzz files matching <regex>\n"); 690 708 printf(" -m, --md5 compute the output's MD5 hash\n"); 709 printf(" -M, --max-memory <n> maximum child virtual memory size in MB\n"); 691 710 printf(" -n, --network fuzz network input\n"); 692 711 printf(" -P, --protect <list> protect bytes and characters in <list>\n"); … … 711 730 printf(" -I <regex> only fuzz files matching <regex>\n"); 712 731 printf(" -m compute the output's MD5 hash\n"); 732 printf(" -M maximum child virtual memory size in MB\n"); 713 733 printf(" -n fuzz network input\n"); 714 734 printf(" -P <list> protect bytes and characters in <list>\n");
Note: See TracChangeset
for help on using the changeset viewer.