- 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)
diff --git a/ChangeLog b/ChangeLog
index cf50b46..9994623 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 1d42298..dca9276 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 @@
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 @@
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 @@
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 @@
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 @@
}
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;
}