aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ifs/preen.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1998-04-07 12:43:57 +0000
committerBruce Evans <bde@FreeBSD.org>1998-04-07 12:43:57 +0000
commit33e60822535a66e7561bb215704a398dd67bb513 (patch)
tree126a060305115c0faae0fdc03180f4a71c6e8380 /sbin/fsck_ifs/preen.c
parent7b0e2080ab9e595a2c7ec6cdac741b7b07210f8b (diff)
downloadsrc-33e60822535a66e7561bb215704a398dd67bb513.tar.gz
src-33e60822535a66e7561bb215704a398dd67bb513.zip
Guess the position of the drive number in the device name better so
that `fsck -p' doesn't check multiple slices on the same drive concurrently. Don't invoke undefined behaviour when searching for the drive number in strange device names. PR: 6129 Reviewed by: phk Submitted by: Yuichi MATSUTAKA <matutaka@osa.att.ne.jp>, but rewritten by me.
Notes
Notes: svn path=/head/; revision=35095
Diffstat (limited to 'sbin/fsck_ifs/preen.c')
-rw-r--r--sbin/fsck_ifs/preen.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sbin/fsck_ifs/preen.c b/sbin/fsck_ifs/preen.c
index 383467b15a91..de9bb5598615 100644
--- a/sbin/fsck_ifs/preen.c
+++ b/sbin/fsck_ifs/preen.c
@@ -206,12 +206,13 @@ finddisk(name)
register char *p;
size_t len;
- for (len = strlen(name), p = name + len - 1; p >= name; --p)
- if (isdigit(*p)) {
- len = p - name + 1;
- break;
- }
-
+ p = strrchr(name, '/');
+ p = p == NULL ? name : p + 1;
+ while (*p != '\0' && !isdigit((u_char)*p))
+ p++;
+ while (isdigit((u_char)*p))
+ p++;
+ len = (size_t)(p - name);
for (dk = disks, dkp = &disks; dk; dkp = &dk->next, dk = dk->next) {
if (strncmp(dk->name, name, len) == 0 &&
dk->name[len] == 0)