summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-02-20 21:13:27 +1100
committerDamien Miller <djm@mindrot.org>2013-02-20 21:13:27 +1100
commit283e575a7db49addd1cffe1a7cb6c5503a98e027 (patch)
tree033746cb9365ef7cd9a98491d77c1ad9fe31def2
parentc31db8cd6e301c8d4024cb9250e3178d13d1be44 (diff)
- 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)
-rw-r--r--ChangeLog7
-rwxr-xr-xregress/modpipe.c25
2 files changed, 25 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index cf50b468..99946236 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
- (tim) [regress/cipher-speed.sh regress/try-ciphers.sh] shell portability fix.
- (tim) [krl.c Makefile.in regress/Makefile regress/modpipe.c] remove unneeded
err.h include from krl.c. Additional portability fixes for modpipe. OK djm
+ - OpenBSD CVS Sync
+ - 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)
20130219
- OpenBSD CVS Sync
diff --git a/regress/modpipe.c b/regress/modpipe.c
index 1d422988..dca92760 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;
}