diff options
author | 2005-05-01 18:15:46 +0000 | |
---|---|---|
committer | 2005-05-01 18:15:46 +0000 | |
commit | a59e3f8de0588fc759ff4d37cb2d39b6b39c2705 (patch) | |
tree | 3a3198293b434457b564edf2da13d0402dbe3cb6 | |
parent | Avoid out of bounds access; Andreas Vogele" <voegelas at gmx dot net> (diff) | |
download | wireguard-openbsd-a59e3f8de0588fc759ff4d37cb2d39b6b39c2705.tar.xz wireguard-openbsd-a59e3f8de0588fc759ff4d37cb2d39b6b39c2705.zip |
When parsing the bootpath, correctly handle ":foo" modifiers if they are
more than one-letter wrong; fixes boot device determination with
/.../ledma:tpe/le...
strings (PR #4192)
-rw-r--r-- | sys/arch/sparc/sparc/autoconf.c | 19 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/autoconf.c | 17 |
2 files changed, 28 insertions, 8 deletions
diff --git a/sys/arch/sparc/sparc/autoconf.c b/sys/arch/sparc/sparc/autoconf.c index 82e83456748..357ef31b836 100644 --- a/sys/arch/sparc/sparc/autoconf.c +++ b/sys/arch/sparc/sparc/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.66 2005/04/21 00:15:43 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.67 2005/05/01 18:15:46 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.73 1997/07/29 09:41:53 fair Exp $ */ /* @@ -393,9 +393,20 @@ bootpath_build() cp = str2hex(++cp, &bp->val[0]); if (*cp == ',') cp = str2hex(++cp, &bp->val[1]); - if (*cp == ':') - /* XXX - we handle just one char */ - bp->val[2] = *++cp - 'a', ++cp; + if (*cp == ':') { + /* + * We only store one character here, + * as we will only use this field + * to compute a partition index + * for block devices. However, it + * might be an ethernet media + * specification, so be sure to + * skip all letters. + */ + bp->val[2] = *++cp - 'a'; + while (*cp != '\0' && *cp != '/') + cp++; + } } else { bp->val[0] = -1; /* no #'s: assume unit 0, no sbus offset/adddress */ diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c index 598cc4f728f..fe7b0c0de3d 100644 --- a/sys/arch/sparc64/sparc64/autoconf.c +++ b/sys/arch/sparc64/sparc64/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.39 2005/04/21 00:15:43 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.40 2005/05/01 18:15:49 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */ /* @@ -310,9 +310,18 @@ bootpath_build() cp = str2hex(++cp, &bp->val[0]); if (*cp == ',') cp = str2hex(++cp, &bp->val[1]); - if (*cp == ':') - /* XXX - we handle just one char */ - bp->val[2] = *++cp - 'a', ++cp; + if (*cp == ':') { + /* + * We only store one character here, as we will + * only use this field to compute a partition + * index for block devices. However, it might + * be an ethernet media specification, so be + * sure to skip all letters. + */ + bp->val[2] = *++cp - 'a'; + while (*cp != '\0' && *cp != '/') + cp++; + } } else { bp->val[0] = -1; /* no #'s: assume unit 0, no sbus offset/adddress */ |