diff options
author | Damien Miller <djm@mindrot.org> | 2013-02-20 11:13:27 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-02-20 11:13:27 +0100 |
commit | 283e575a7db49addd1cffe1a7cb6c5503a98e027 (patch) | |
tree | 033746cb9365ef7cd9a98491d77c1ad9fe31def2 /regress/modpipe.c | |
parent | - (tim) [krl.c Makefile.in regress/Makefile regress/modpipe.c] remove unneeded (diff) | |
download | openssh-283e575a7db49addd1cffe1a7cb6c5503a98e027.tar.xz openssh-283e575a7db49addd1cffe1a7cb6c5503a98e027.zip |
- djm@cvs.openbsd.org 2013/02/20 08:27:50
[regress/integrity.sh regress/modpipe.c]
Add an option to modpipe that warns if the modification offset it not
reached in it's stream and turn it on for t-integrity. This should catch
cases where the session is not fuzzed for being too short (cf. my last
"oops" commit)
Diffstat (limited to 'regress/modpipe.c')
-rwxr-xr-x | regress/modpipe.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/regress/modpipe.c b/regress/modpipe.c index 1d4229885..dca927603 100755 --- a/regress/modpipe.c +++ b/regress/modpipe.c @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: modpipe.c,v 1.3 2013/02/20 03:01:52 tim Exp $ */ +/* $Id: modpipe.c,v 1.4 2013/02/20 10:13:29 djm Exp $ */ #include <sys/types.h> #include <unistd.h> @@ -56,7 +56,7 @@ errx(int r, const char *fmt, ...) static void usage(void) { - fprintf(stderr, "Usage: modpipe [-m modspec ...] < in > out\n"); + fprintf(stderr, "Usage: modpipe -w [-m modspec ...] < in > out\n"); fprintf(stderr, "modspec is one of:\n"); fprintf(stderr, " xor:offset:value - XOR \"value\" at \"offset\"\n"); fprintf(stderr, " andor:offset:val1:val2 - AND \"val1\" then OR \"val2\" at \"offset\"\n"); @@ -100,15 +100,18 @@ main(int argc, char **argv) size_t total; ssize_t r, s, o; struct modification mods[MAX_MODIFICATIONS]; - u_int i, num_mods = 0; + u_int i, wflag = 0, num_mods = 0; - while ((ch = getopt(argc, argv, "m:")) != -1) { + while ((ch = getopt(argc, argv, "wm:")) != -1) { switch (ch) { case 'm': if (num_mods >= MAX_MODIFICATIONS) errx(1, "Too many modifications"); parse_modification(optarg, &(mods[num_mods++])); break; + case 'w': + wflag = 1; + break; default: usage(); /* NOTREACHED */ @@ -117,7 +120,7 @@ main(int argc, char **argv) for (total = 0;;) { r = s = read(STDIN_FILENO, buf, sizeof(buf)); if (r == 0) - return 0; + break; if (r < 0) { if (errno == EAGAIN || errno == EINTR) continue; @@ -140,7 +143,7 @@ main(int argc, char **argv) for (o = 0; o < s; o += r) { r = write(STDOUT_FILENO, buf, s - o); if (r == 0) - return 0; + break; if (r < 0) { if (errno == EAGAIN || errno == EINTR) continue; @@ -149,5 +152,13 @@ main(int argc, char **argv) } total += s; } - return 0; + /* Warn if modifications not reached in input stream */ + r = 0; + for (i = 0; wflag && i < num_mods; i++) { + if (mods[i].offset < total) + continue; + r = 1; + fprintf(stderr, "modpipe: warning - mod %u not reached\n", i); + } + return r; } |