diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2007-05-18 16:26:39 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2007-05-18 16:26:39 +0000 |
commit | 2cbe0e70ecddb5578d4de657562da32708986d25 (patch) | |
tree | 252a407c8de824cf555eb0a6423c5218595bd05d /sys/kern | |
parent | a15e9ff6481611766ed71b5425d88d7bc7aaf4bc (diff) |
Dont write to the string passed to parsedisk(), ok deraadt@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_disk.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index bf6a4c32e04..b085a719e56 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.41 2007/05/18 07:37:18 deraadt Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.42 2007/05/18 16:26:38 drahn Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -542,16 +542,15 @@ struct device * parsedisk(char *str, int len, int defpart, dev_t *devp) { struct device *dv; - char *cp, c; + char c; int majdev, part; if (len == 0) return (NULL); - cp = str + len - 1; - c = *cp; + c = str[len-1]; if (c >= 'a' && (c - 'a') < MAXPARTITIONS) { part = c - 'a'; - *cp = '\0'; + len -= 1; } else part = defpart; @@ -564,7 +563,8 @@ parsedisk(char *str, int len, int defpart, dev_t *devp) TAILQ_FOREACH(dv, &alldevs, dv_list) { if (dv->dv_class == DV_DISK && - strcmp(str, dv->dv_xname) == 0) { + strncmp(str, dv->dv_xname, len) == 0 && + dv->dv_xname[len] == '\0') { #ifdef RAMDISK_HOOKS gotdisk: #endif @@ -576,14 +576,14 @@ gotdisk: } #if defined(NFSCLIENT) if (dv->dv_class == DV_IFNET && - strcmp(str, dv->dv_xname) == 0) { + strncmp(str, dv->dv_xname, len) == 0 && + dv->dv_xname[len] == '\0') { *devp = NODEV; break; } #endif } - *cp = c; return (dv); } |