summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rwxr-xr-xregress/modpipe.c25
2 files changed, 25 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index cf50b4688..99946236e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
2 - (tim) [regress/cipher-speed.sh regress/try-ciphers.sh] shell portability fix. 2 - (tim) [regress/cipher-speed.sh regress/try-ciphers.sh] shell portability fix.
3 - (tim) [krl.c Makefile.in regress/Makefile regress/modpipe.c] remove unneeded 3 - (tim) [krl.c Makefile.in regress/Makefile regress/modpipe.c] remove unneeded
4 err.h include from krl.c. Additional portability fixes for modpipe. OK djm 4 err.h include from krl.c. Additional portability fixes for modpipe. OK djm
5 - OpenBSD CVS Sync
6 - djm@cvs.openbsd.org 2013/02/20 08:27:50
7 [regress/integrity.sh regress/modpipe.c]
8 Add an option to modpipe that warns if the modification offset it not
9 reached in it's stream and turn it on for t-integrity. This should catch
10 cases where the session is not fuzzed for being too short (cf. my last
11 "oops" commit)
5 12
620130219 1320130219
7 - OpenBSD CVS Sync 14 - OpenBSD CVS Sync
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 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17/* $Id: modpipe.c,v 1.3 2013/02/20 03:01:52 tim Exp $ */ 17/* $Id: modpipe.c,v 1.4 2013/02/20 10:13:29 djm Exp $ */
18 18
19#include <sys/types.h> 19#include <sys/types.h>
20#include <unistd.h> 20#include <unistd.h>
@@ -56,7 +56,7 @@ errx(int r, const char *fmt, ...)
56static void 56static void
57usage(void) 57usage(void)
58{ 58{
59 fprintf(stderr, "Usage: modpipe [-m modspec ...] < in > out\n"); 59 fprintf(stderr, "Usage: modpipe -w [-m modspec ...] < in > out\n");
60 fprintf(stderr, "modspec is one of:\n"); 60 fprintf(stderr, "modspec is one of:\n");
61 fprintf(stderr, " xor:offset:value - XOR \"value\" at \"offset\"\n"); 61 fprintf(stderr, " xor:offset:value - XOR \"value\" at \"offset\"\n");
62 fprintf(stderr, " andor:offset:val1:val2 - AND \"val1\" then OR \"val2\" at \"offset\"\n"); 62 fprintf(stderr, " andor:offset:val1:val2 - AND \"val1\" then OR \"val2\" at \"offset\"\n");
@@ -100,15 +100,18 @@ main(int argc, char **argv)
100 size_t total; 100 size_t total;
101 ssize_t r, s, o; 101 ssize_t r, s, o;
102 struct modification mods[MAX_MODIFICATIONS]; 102 struct modification mods[MAX_MODIFICATIONS];
103 u_int i, num_mods = 0; 103 u_int i, wflag = 0, num_mods = 0;
104 104
105 while ((ch = getopt(argc, argv, "m:")) != -1) { 105 while ((ch = getopt(argc, argv, "wm:")) != -1) {
106 switch (ch) { 106 switch (ch) {
107 case 'm': 107 case 'm':
108 if (num_mods >= MAX_MODIFICATIONS) 108 if (num_mods >= MAX_MODIFICATIONS)
109 errx(1, "Too many modifications"); 109 errx(1, "Too many modifications");
110 parse_modification(optarg, &(mods[num_mods++])); 110 parse_modification(optarg, &(mods[num_mods++]));
111 break; 111 break;
112 case 'w':
113 wflag = 1;
114 break;
112 default: 115 default:
113 usage(); 116 usage();
114 /* NOTREACHED */ 117 /* NOTREACHED */
@@ -117,7 +120,7 @@ main(int argc, char **argv)
117 for (total = 0;;) { 120 for (total = 0;;) {
118 r = s = read(STDIN_FILENO, buf, sizeof(buf)); 121 r = s = read(STDIN_FILENO, buf, sizeof(buf));
119 if (r == 0) 122 if (r == 0)
120 return 0; 123 break;
121 if (r < 0) { 124 if (r < 0) {
122 if (errno == EAGAIN || errno == EINTR) 125 if (errno == EAGAIN || errno == EINTR)
123 continue; 126 continue;
@@ -140,7 +143,7 @@ main(int argc, char **argv)
140 for (o = 0; o < s; o += r) { 143 for (o = 0; o < s; o += r) {
141 r = write(STDOUT_FILENO, buf, s - o); 144 r = write(STDOUT_FILENO, buf, s - o);
142 if (r == 0) 145 if (r == 0)
143 return 0; 146 break;
144 if (r < 0) { 147 if (r < 0) {
145 if (errno == EAGAIN || errno == EINTR) 148 if (errno == EAGAIN || errno == EINTR)
146 continue; 149 continue;
@@ -149,5 +152,13 @@ main(int argc, char **argv)
149 } 152 }
150 total += s; 153 total += s;
151 } 154 }
152 return 0; 155 /* Warn if modifications not reached in input stream */
156 r = 0;
157 for (i = 0; wflag && i < num_mods; i++) {
158 if (mods[i].offset < total)
159 continue;
160 r = 1;
161 fprintf(stderr, "modpipe: warning - mod %u not reached\n", i);
162 }
163 return r;
153} 164}