diff options
author | Ian Lepore <ian@FreeBSD.org> | 2019-02-20 03:00:55 +0000 |
---|---|---|
committer | Ian Lepore <ian@FreeBSD.org> | 2019-02-20 03:00:55 +0000 |
commit | 98934c68430be60295c3311edba815a206335e11 (patch) | |
tree | d4a68e83a5d00b2accfaa9659fccaa9d36588d3e /stand/uboot | |
parent | 02295caf4333432bf3909c35d53ba74d2d8770db (diff) | |
download | src-test2-98934c68430be60295c3311edba815a206335e11.tar.gz src-test2-98934c68430be60295c3311edba815a206335e11.zip |
Fix the handling of legacy-format devices in the u-boot loaderdev variable.
When I added support for the standard loader(8) disk0s2a: type formats,
the parsing of legacy format was broken because it also contains a colon,
but it comes before the slice and partition. That would cause disk_parsedev()
to return success with the slice and partition set to wildcard values.
This change examines the string first, and if it contains spaces, dots, or
a colon at any position other than the end, it must be a legacy-format
string and we don't even try to use disk_parsedev() on it.
Reported by: Manuel Stuhn
Notes
Notes:
svn path=/head/; revision=344335
Diffstat (limited to 'stand/uboot')
-rw-r--r-- | stand/uboot/common/main.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/stand/uboot/common/main.c b/stand/uboot/common/main.c index d420aa95a598..df53097c2a79 100644 --- a/stand/uboot/common/main.c +++ b/stand/uboot/common/main.c @@ -226,16 +226,23 @@ get_load_device(int *type, int *unit, int *slice, int *partition) p = get_device_type(devstr, type); /* - * If type is DEV_TYP_STOR we have a disk-like device. If we can parse - * the remainder of the string as a standard unit+slice+partition (e.g., - * 0s2a or 1p12), return those results. Otherwise we'll fall through to - * the code that parses the legacy format. + * If type is DEV_TYP_STOR we have a disk-like device. If the remainder + * of the string contains spaces, dots, or a colon in any location other + * than the last char, it's legacy format. Otherwise it might be + * standard loader(8) format (e.g., disk0s2a or mmc1p12), so try to + * parse the remainder of the string as such, and if it works, return + * those results. Otherwise we'll fall through to the code that parses + * the legacy format. */ - if ((*type & DEV_TYP_STOR) && disk_parsedev(&dev, p, NULL) == 0) { - *unit = dev.dd.d_unit; - *slice = dev.d_slice; - *partition = dev.d_partition; - return; + if (*type & DEV_TYP_STOR) { + size_t len = strlen(p); + if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 && + disk_parsedev(&dev, p, NULL) == 0) { + *unit = dev.dd.d_unit; + *slice = dev.d_slice; + *partition = dev.d_partition; + return; + } } /* Ignore optional spaces after the device name. */ |