sbin/geom/class/part/geom_part.c
Always validate the return of find_geomcfg(). It could be NULL, for example when the geom is withering. Approved by: ken (mentor) Sponsored by: Spectra Logic Corporation MFC after: 3 weeks
This commit is contained in:
parent
fce0413b0a
commit
86b2e94a3d
@ -364,7 +364,11 @@ gpart_autofill_resize(struct gctl_req *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
offset = (pp->lg_stripeoffset / pp->lg_sectorsize) % alignment;
|
offset = (pp->lg_stripeoffset / pp->lg_sectorsize) % alignment;
|
||||||
last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0);
|
s = find_geomcfg(gp, "last");
|
||||||
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Final block not found for geom %s",
|
||||||
|
gp->lg_name);
|
||||||
|
last = (off_t)strtoimax(s, NULL, 0);
|
||||||
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
|
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
|
||||||
s = find_provcfg(pp, "index");
|
s = find_provcfg(pp, "index");
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
@ -502,8 +506,16 @@ gpart_autofill(struct gctl_req *req)
|
|||||||
if (size > alignment)
|
if (size > alignment)
|
||||||
size = ALIGNDOWN(size, alignment);
|
size = ALIGNDOWN(size, alignment);
|
||||||
|
|
||||||
first = (off_t)strtoimax(find_geomcfg(gp, "first"), NULL, 0);
|
s = find_geomcfg(gp, "first");
|
||||||
last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0);
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Starting block not found for geom %s",
|
||||||
|
gp->lg_name);
|
||||||
|
first = (off_t)strtoimax(s, NULL, 0);
|
||||||
|
s = find_geomcfg(gp, "last");
|
||||||
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Final block not found for geom %s",
|
||||||
|
gp->lg_name);
|
||||||
|
last = (off_t)strtoimax(s, NULL, 0);
|
||||||
grade = ~0ULL;
|
grade = ~0ULL;
|
||||||
a_first = ALIGNUP(first + offset, alignment);
|
a_first = ALIGNUP(first + offset, alignment);
|
||||||
last = ALIGNDOWN(last + offset, alignment);
|
last = ALIGNDOWN(last + offset, alignment);
|
||||||
@ -587,12 +599,22 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
|
|||||||
int idx, wblocks, wname, wmax;
|
int idx, wblocks, wname, wmax;
|
||||||
|
|
||||||
scheme = find_geomcfg(gp, "scheme");
|
scheme = find_geomcfg(gp, "scheme");
|
||||||
|
if (scheme == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);
|
||||||
s = find_geomcfg(gp, "first");
|
s = find_geomcfg(gp, "first");
|
||||||
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Starting block not found for geom %s",
|
||||||
|
gp->lg_name);
|
||||||
first = (off_t)strtoimax(s, NULL, 0);
|
first = (off_t)strtoimax(s, NULL, 0);
|
||||||
s = find_geomcfg(gp, "last");
|
s = find_geomcfg(gp, "last");
|
||||||
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Final block not found for geom %s",
|
||||||
|
gp->lg_name);
|
||||||
last = (off_t)strtoimax(s, NULL, 0);
|
last = (off_t)strtoimax(s, NULL, 0);
|
||||||
wblocks = strlen(s);
|
wblocks = strlen(s);
|
||||||
s = find_geomcfg(gp, "state");
|
s = find_geomcfg(gp, "state");
|
||||||
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "State not found for geom %s", gp->lg_name);
|
||||||
if (s != NULL && *s != 'C')
|
if (s != NULL && *s != 'C')
|
||||||
s = NULL;
|
s = NULL;
|
||||||
wmax = strlen(gp->lg_name);
|
wmax = strlen(gp->lg_name);
|
||||||
@ -748,6 +770,8 @@ gpart_backup(struct gctl_req *req, unsigned int fl __unused)
|
|||||||
abort();
|
abort();
|
||||||
pp = LIST_FIRST(&gp->lg_consumer)->lg_provider;
|
pp = LIST_FIRST(&gp->lg_consumer)->lg_provider;
|
||||||
s = find_geomcfg(gp, "last");
|
s = find_geomcfg(gp, "last");
|
||||||
|
if (s == NULL)
|
||||||
|
abort();
|
||||||
wblocks = strlen(s);
|
wblocks = strlen(s);
|
||||||
wtype = 0;
|
wtype = 0;
|
||||||
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
|
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
|
||||||
@ -757,6 +781,8 @@ gpart_backup(struct gctl_req *req, unsigned int fl __unused)
|
|||||||
wtype = i;
|
wtype = i;
|
||||||
}
|
}
|
||||||
s = find_geomcfg(gp, "entries");
|
s = find_geomcfg(gp, "entries");
|
||||||
|
if (s == NULL)
|
||||||
|
abort();
|
||||||
windex = strlen(s);
|
windex = strlen(s);
|
||||||
printf("%s %s\n", scheme, s);
|
printf("%s %s\n", scheme, s);
|
||||||
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
|
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
|
||||||
@ -1177,6 +1203,8 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
|
|||||||
if (gp == NULL)
|
if (gp == NULL)
|
||||||
errx(EXIT_FAILURE, "No such geom: %s.", s);
|
errx(EXIT_FAILURE, "No such geom: %s.", s);
|
||||||
s = find_geomcfg(gp, "scheme");
|
s = find_geomcfg(gp, "scheme");
|
||||||
|
if (s == NULL)
|
||||||
|
errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);
|
||||||
vtoc8 = 0;
|
vtoc8 = 0;
|
||||||
if (strcmp(s, "VTOC8") == 0)
|
if (strcmp(s, "VTOC8") == 0)
|
||||||
vtoc8 = 1;
|
vtoc8 = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user