FreeBSD Bugzilla – Attachment 155638 Details for
Bug 199476
[patch] panic when geom_uncompress tastes large filesystems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to fix panic when tasting large compressed filesystems
geom_uncompress.diff (text/plain), 1.71 KB, created by
Keith White
on 2015-04-16 01:51:33 UTC
(
hide
)
Description:
patch to fix panic when tasting large compressed filesystems
Filename:
MIME Type:
Creator:
Keith White
Created:
2015-04-16 01:51:33 UTC
Size:
1.71 KB
patch
obsolete
>Index: sys/geom/uncompress/g_uncompress.c >=================================================================== >--- sys/geom/uncompress/g_uncompress.c (revision 281308) >+++ sys/geom/uncompress/g_uncompress.c (working copy) >@@ -464,7 +464,7 @@ > struct g_provider *pp2; > struct g_consumer *cp; > struct g_geom *gp; >- uint32_t i, total_offsets, type; >+ uint32_t i, total_offsets, type, offsets_read, blk; > uint8_t *buf; > int error; > >@@ -557,18 +557,33 @@ > gp->name, sc->nblocks); > goto err; > } >- free(buf, M_GEOM); > >- i = roundup((sizeof(struct cloop_header) + >- total_offsets * sizeof(uint64_t)), pp->sectorsize); >- buf = g_read_data(cp, 0, i, NULL); >- if (buf == NULL) >- goto err; > sc->offsets = malloc(total_offsets * sizeof(uint64_t), > M_GEOM_UNCOMPRESS, M_WAITOK); >- for (i = 0; i <= total_offsets; i++) { >+ offsets_read = MIN(total_offsets, >+ (pp->sectorsize - sizeof(struct cloop_header)) / sizeof(uint64_t)); >+ for (i = 0; i < offsets_read; i++) > sc->offsets[i] = be64toh(((uint64_t *) > (buf+sizeof(struct cloop_header)))[i]); >+ DPRINTF(("%s: %u offsets in the first sector\n", >+ gp->name, offsets_read)); >+ for (blk = 1; offsets_read < total_offsets; blk++) { >+ uint32_t nread; >+ >+ free(buf, M_GEOM); >+ buf = g_read_data( >+ cp, blk * pp->sectorsize, pp->sectorsize, NULL); >+ if (buf == NULL) >+ goto err; >+ nread = MIN(total_offsets - offsets_read, >+ pp->sectorsize / sizeof(uint64_t)); >+ DPRINTF(("%s: %u offsets read from sector %d\n", >+ gp->name, nread, blk)); >+ for (i = 0; i < nread; i++) { >+ sc->offsets[offsets_read + i] = >+ be64toh(((uint64_t *) buf)[i]); >+ } >+ offsets_read += nread; > } > free(buf, M_GEOM); > DPRINTF(("%s: done reading offsets\n", gp->name));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 199476
: 155638 |
156873
|
156876