- 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)
This commit is contained in:
Damien Miller 2013-02-20 21:13:27 +11:00
parent c31db8cd6e
commit 283e575a7d
2 changed files with 25 additions and 7 deletions

View File

@ -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

View File

@ -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;
}