summaryrefslogtreecommitdiffstats
path: root/libblkid/src/superblocks/zfs.c
diff options
context:
space:
mode:
authorKarel Zak2015-09-22 15:27:39 +0200
committerKarel Zak2015-09-24 11:10:09 +0200
commit9325a8be9e55cc01d9f580e14dd2193829245183 (patch)
tree14723533bbbd0e6bcfaa959bcd88404d7e468e2a /libblkid/src/superblocks/zfs.c
parentlibblkid: (promise raid) cleanup code (diff)
downloadkernel-qcow2-util-linux-9325a8be9e55cc01d9f580e14dd2193829245183.tar.gz
kernel-qcow2-util-linux-9325a8be9e55cc01d9f580e14dd2193829245183.tar.xz
kernel-qcow2-util-linux-9325a8be9e55cc01d9f580e14dd2193829245183.zip
libblkid: (zfs) keep bufferes read-only
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/superblocks/zfs.c')
-rw-r--r--libblkid/src/superblocks/zfs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c
index 8f82d1e6b..60e6c7aa8 100644
--- a/libblkid/src/superblocks/zfs.c
+++ b/libblkid/src/superblocks/zfs.c
@@ -70,9 +70,10 @@ struct nvlist {
static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
{
+ unsigned char *p, buff[4096];
struct nvlist *nvl;
struct nvpair *nvp;
- size_t left = 4096;
+ size_t left = sizeof(buff);
int found = 0;
offset = (offset & ~(VDEV_LABEL_SIZE - 1)) + VDEV_LABEL_NVPAIR;
@@ -81,10 +82,14 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
* the first 4k (left) of the nvlist. This is true for all pools
* I've seen, and simplifies this code somewhat, because we don't
* have to handle an nvpair crossing a buffer boundary. */
- nvl = (struct nvlist *)blkid_probe_get_buffer(pr, offset, left);
- if (nvl == NULL)
+ p = blkid_probe_get_buffer(pr, offset, left);
+ if (!p)
return;
+ /* libblkid buffers are strictly readonly, but the code below modifies nvpair etc. */
+ memcpy(buff, p, sizeof(buff));
+ nvl = (struct nvlist *) buff;
+
nvdebug("zfs_extract: nvlist offset %llu\n", offset);
nvp = &nvl->nvl_nvpair;