diff options
Diffstat (limited to 'regress/modpipe.c')
-rwxr-xr-x | regress/modpipe.c | 21 |
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 | |||
74 | parse_modification(const char *s, struct modification *m) | 76 | parse_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 | } |