diff mbox series

[OpenWrt-Devel] fstools: fix libblkid-tiny ntfs uuid detection

Message ID HK0PR02MB3153A515077098D6209D1F4FEEB90@HK0PR02MB3153.apcprd02.prod.outlook.com
State Changes Requested, archived
Headers show
Series [OpenWrt-Devel] fstools: fix libblkid-tiny ntfs uuid detection | expand

Commit Message

z @ Sept. 3, 2019, 4 p.m. UTC
detect ntfs uuid fails because blkid_probe_get_buffer override memory of buf,
so move blkid_probe_sprintf_uuid to before blkid_probe_get_buffer

Signed-off-by: Haiqiang Xu <haig8@msn.com>
---
 libblkid-tiny/ntfs.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Rafał Miłecki Sept. 3, 2019, 4:53 p.m. UTC | #1
On Tue, 3 Sep 2019 at 18:00, z @ <haig8@msn.com> wrote:
> detect ntfs uuid fails because blkid_probe_get_buffer override memory of buf,
> so move blkid_probe_sprintf_uuid to before blkid_probe_get_buffer
>
> Signed-off-by: Haiqiang Xu <haig8@msn.com>

I'm not sure about this solution. It's a workaround for the issue I
reported last week, see:
libblkid-tiny: bugged buffer management
http://lists.infradead.org/pipermail/openwrt-devel/2019-August/018651.html

I'd rather see blkid_probe_get_buffer() fixed I think.
diff mbox series

Patch

diff --git a/libblkid-tiny/ntfs.c b/libblkid-tiny/ntfs.c
index 93c1d88..51252ea 100644
--- a/libblkid-tiny/ntfs.c
+++ b/libblkid-tiny/ntfs.c
@@ -158,6 +158,11 @@  static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag)
 			sectors_per_cluster, nr_clusters,
 			off));
 
+	blkid_probe_sprintf_uuid(pr,
+			(unsigned char *) &ns->volume_serial,
+			sizeof(ns->volume_serial),
+			"%016" PRIX64, le64_to_cpu(ns->volume_serial));
+
 	buf_mft = blkid_probe_get_buffer(pr, off, mft_record_size);
 	if (!buf_mft)
 		return errno ? -errno : 1;
@@ -206,10 +211,6 @@  static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag)
 	}
 #endif
 
-	blkid_probe_sprintf_uuid(pr,
-			(unsigned char *) &ns->volume_serial,
-			sizeof(ns->volume_serial),
-			"%016" PRIX64, le64_to_cpu(ns->volume_serial));
 	return 0;
 }