Don't assume the length of MD_NAME is 2.
This commit is contained in:
parent
2885b42173
commit
78baea25b2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78525
@ -147,7 +147,7 @@ main(int argc, char **argv)
|
|||||||
if (!strncmp(optarg, "/dev/", 5))
|
if (!strncmp(optarg, "/dev/", 5))
|
||||||
optarg += 5;
|
optarg += 5;
|
||||||
if (!strncmp(optarg, MD_NAME, sizeof(MD_NAME) - 1))
|
if (!strncmp(optarg, MD_NAME, sizeof(MD_NAME) - 1))
|
||||||
optarg += 2;
|
optarg += sizeof(MD_NAME) - 1;
|
||||||
mdio.md_unit = strtoul(optarg, &p, 0);
|
mdio.md_unit = strtoul(optarg, &p, 0);
|
||||||
if ((unsigned)mdio.md_unit == ULONG_MAX || *p != '\0')
|
if ((unsigned)mdio.md_unit == ULONG_MAX || *p != '\0')
|
||||||
errx(1, "bad unit: %s", optarg);
|
errx(1, "bad unit: %s", optarg);
|
||||||
@ -214,7 +214,7 @@ list(const int fd)
|
|||||||
(p2 = strsep(&p, " ")) != NULL;) {
|
(p2 = strsep(&p, " ")) != NULL;) {
|
||||||
if (strncmp(p2, MD_NAME, sizeof(MD_NAME) - 1) != 0)
|
if (strncmp(p2, MD_NAME, sizeof(MD_NAME) - 1) != 0)
|
||||||
continue;
|
continue;
|
||||||
p2 += 2;
|
p2 += sizeof(MD_NAME) - 1;
|
||||||
unit = strtoul(p2, &p3, 10);
|
unit = strtoul(p2, &p3, 10);
|
||||||
if (p2 == p3)
|
if (p2 == p3)
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user