diff options
Diffstat (limited to 'regress')
-rwxr-xr-x | regress/usr.bin/ssh/modpipe.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/regress/usr.bin/ssh/modpipe.c b/regress/usr.bin/ssh/modpipe.c index bcec288f39b..d6394c1eb9f 100755 --- a/regress/usr.bin/ssh/modpipe.c +++ b/regress/usr.bin/ssh/modpipe.c @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: modpipe.c,v 1.4 2013/02/20 08:29:27 djm Exp $ */ +/* $OpenBSD: modpipe.c,v 1.5 2013/05/10 03:46:14 djm Exp $ */ #include <sys/types.h> #include <unistd.h> @@ -45,20 +45,29 @@ static void parse_modification(const char *s, struct modification *m) { char what[16+1]; - int n; + int n, m1, m2; bzero(m, sizeof(*m)); - if ((n = sscanf(s, "%16[^:]%*[:]%lli%*[:]%hhi%*[:]%hhi", - what, &m->offset, &m->m1, &m->m2)) < 3) + if ((n = sscanf(s, "%16[^:]%*[:]%lli%*[:]%i%*[:]%i", + what, &m->offset, &m1, &m2)) < 3) errx(1, "Invalid modification spec \"%s\"", s); if (strcasecmp(what, "xor") == 0) { - m->what = MOD_XOR; if (n > 3) errx(1, "Invalid modification spec \"%s\"", s); + if (m1 < 0 || m1 > 0xff) + errx(1, "Invalid XOR modification value"); + m->what = MOD_XOR; + m->m1 = m1; } else if (strcasecmp(what, "andor") == 0) { - m->what = MOD_AND_OR; if (n != 4) errx(1, "Invalid modification spec \"%s\"", s); + if (m1 < 0 || m1 > 0xff) + errx(1, "Invalid AND modification value"); + if (m2 < 0 || m2 > 0xff) + errx(1, "Invalid OR modification value"); + m->what = MOD_AND_OR; + m->m1 = m1; + m->m2 = m2; } else errx(1, "Invalid modification type \"%s\"", what); } |