|
|
05ad79 |
From eeb629102da9a9a916d201bbd5f13ee7ad23844d Mon Sep 17 00:00:00 2001
|
|
|
05ad79 |
From: Karel Zak <kzak@redhat.com>
|
|
|
05ad79 |
Date: Tue, 22 Sep 2015 15:27:39 +0200
|
|
|
05ad79 |
Subject: [PATCH 110/116] libblkid: (zfs) keep bufferes read-only
|
|
|
05ad79 |
|
|
|
05ad79 |
Upstream: https://github.com/karelzak/util-linux/commit/9325a8be9e55cc01d9f580e14dd2193829245183
|
|
|
05ad79 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1392661
|
|
|
05ad79 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
05ad79 |
---
|
|
|
05ad79 |
libblkid/src/superblocks/zfs.c | 11 ++++++++---
|
|
|
05ad79 |
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
05ad79 |
|
|
|
05ad79 |
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c
|
|
|
05ad79 |
index 9b5601e..8e88b39 100644
|
|
|
05ad79 |
--- a/libblkid/src/superblocks/zfs.c
|
|
|
05ad79 |
+++ b/libblkid/src/superblocks/zfs.c
|
|
|
05ad79 |
@@ -70,9 +70,10 @@ struct nvlist {
|
|
|
05ad79 |
|
|
|
05ad79 |
static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
|
|
|
05ad79 |
{
|
|
|
05ad79 |
+ unsigned char *p, buff[4096];
|
|
|
05ad79 |
struct nvlist *nvl;
|
|
|
05ad79 |
struct nvpair *nvp;
|
|
|
05ad79 |
- size_t left = 4096;
|
|
|
05ad79 |
+ size_t left = sizeof(buff);
|
|
|
05ad79 |
int found = 0;
|
|
|
05ad79 |
|
|
|
05ad79 |
offset = (offset & ~(VDEV_LABEL_SIZE - 1)) + VDEV_LABEL_NVPAIR;
|
|
|
05ad79 |
@@ -81,10 +82,14 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
|
|
|
05ad79 |
* the first 4k (left) of the nvlist. This is true for all pools
|
|
|
05ad79 |
* I've seen, and simplifies this code somewhat, because we don't
|
|
|
05ad79 |
* have to handle an nvpair crossing a buffer boundary. */
|
|
|
05ad79 |
- nvl = (struct nvlist *)blkid_probe_get_buffer(pr, offset, left);
|
|
|
05ad79 |
- if (nvl == NULL)
|
|
|
05ad79 |
+ p = blkid_probe_get_buffer(pr, offset, left);
|
|
|
05ad79 |
+ if (!p)
|
|
|
05ad79 |
return;
|
|
|
05ad79 |
|
|
|
05ad79 |
+ /* libblkid buffers are strictly readonly, but the code below modifies nvpair etc. */
|
|
|
05ad79 |
+ memcpy(buff, p, sizeof(buff));
|
|
|
05ad79 |
+ nvl = (struct nvlist *) buff;
|
|
|
05ad79 |
+
|
|
|
05ad79 |
nvdebug("zfs_extract: nvlist offset %llu\n", offset);
|
|
|
05ad79 |
|
|
|
05ad79 |
nvp = &nvl->nvl_nvpair;
|
|
|
05ad79 |
--
|
|
|
05ad79 |
2.9.3
|
|
|
05ad79 |
|