summaryrefslogtreecommitdiff
path: root/regress/modpipe.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-03-05 09:49:00 +1100
committerDamien Miller <djm@mindrot.org>2013-03-05 09:49:00 +1100
commit43e5e60badb827104363169c333b0b7eadb0d09a (patch)
tree84cc038ca19768bed4cc247c6c4b030e16c57f03 /regress/modpipe.c
parent21f591b6d975301fd005b4c031dffa0efefded08 (diff)
- (djm) [regress/modpipe.c] Compilation fix for AIX and parsing fix for
HP/UX. Spotted by Kevin Brott
Diffstat (limited to 'regress/modpipe.c')
-rwxr-xr-xregress/modpipe.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/regress/modpipe.c b/regress/modpipe.c
index 1f17e41f8..9629aa80b 100755
--- a/regress/modpipe.c
+++ b/regress/modpipe.c
@@ -16,6 +16,8 @@
16 16
17/* $OpenBSD: modpipe.c,v 1.4 2013/02/20 08:29:27 djm Exp $ */ 17/* $OpenBSD: modpipe.c,v 1.4 2013/02/20 08:29:27 djm Exp $ */
18 18
19#include "includes.h"
20
19#include <sys/types.h> 21#include <sys/types.h>
20#include <unistd.h> 22#include <unistd.h>
21#include <stdio.h> 23#include <stdio.h>
@@ -74,20 +76,29 @@ static void
74parse_modification(const char *s, struct modification *m) 76parse_modification(const char *s, struct modification *m)
75{ 77{
76 char what[16+1]; 78 char what[16+1];
77 int n; 79 int n, m1, m2;
78 80
79 bzero(m, sizeof(*m)); 81 bzero(m, sizeof(*m));
80 if ((n = sscanf(s, "%16[^:]%*[:]%lli%*[:]%hhi%*[:]%hhi", 82 if ((n = sscanf(s, "%16[^:]%*[:]%lli%*[:]%i%*[:]%i",
81 what, &m->offset, &m->m1, &m->m2)) < 3) 83 what, &m->offset, &m1, &m2)) < 3)
82 errx(1, "Invalid modification spec \"%s\"", s); 84 errx(1, "Invalid modification spec \"%s\"", s);
83 if (strcasecmp(what, "xor") == 0) { 85 if (strcasecmp(what, "xor") == 0) {
84 m->what = MOD_XOR;
85 if (n > 3) 86 if (n > 3)
86 errx(1, "Invalid modification spec \"%s\"", s); 87 errx(1, "Invalid modification spec \"%s\"", s);
88 if (m1 < 0 || m1 > 0xff)
89 errx(1, "Invalid XOR modification value");
90 m->what = MOD_XOR;
91 m->m1 = m1;
87 } else if (strcasecmp(what, "andor") == 0) { 92 } else if (strcasecmp(what, "andor") == 0) {
88 m->what = MOD_AND_OR;
89 if (n != 4) 93 if (n != 4)
90 errx(1, "Invalid modification spec \"%s\"", s); 94 errx(1, "Invalid modification spec \"%s\"", s);
95 if (m1 < 0 || m1 > 0xff)
96 errx(1, "Invalid AND modification value");
97 if (m2 < 0 || m2 > 0xff)
98 errx(1, "Invalid OR modification value");
99 m->what = MOD_AND_OR;
100 m->m1 = m1;
101 m->m2 = m2;
91 } else 102 } else
92 errx(1, "Invalid modification type \"%s\"", what); 103 errx(1, "Invalid modification type \"%s\"", what);
93} 104}