backport libgfs2: Fix pointer cast byte order issue
This commit is contained in:
parent
c248667084
commit
d7ac5d7226
52
0001-libgfs2-Fix-pointer-cast-byte-order-issue.patch
Normal file
52
0001-libgfs2-Fix-pointer-cast-byte-order-issue.patch
Normal file
@ -0,0 +1,52 @@
|
||||
From 57553571df2f33ec45a81fa5599873ddfc890c92 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Price <anprice@redhat.com>
|
||||
Date: Thu, 6 Sep 2018 14:28:19 +0100
|
||||
Subject: [PATCH] libgfs2: Fix pointer cast byte order issue
|
||||
|
||||
lgfs2_field_assign() currently uses pointer casting to achieve generic
|
||||
integer assignment based on the width of the field, but this is broken
|
||||
as a uin32_t field can be assigned the value from the high bytes of the
|
||||
uint64_t value, for instance. To fix this, store the value into a
|
||||
uint64_t before casting to the narrower types.
|
||||
|
||||
Signed-off-by: Andrew Price <anprice@redhat.com>
|
||||
---
|
||||
gfs2/libgfs2/meta.c | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
|
||||
index a8289466..e0ea4912 100644
|
||||
--- a/gfs2/libgfs2/meta.c
|
||||
+++ b/gfs2/libgfs2/meta.c
|
||||
@@ -940,6 +940,7 @@ int lgfs2_field_str(char *str, const size_t size, const char *blk, const struct
|
||||
int lgfs2_field_assign(char *blk, const struct lgfs2_metafield *field, const void *val)
|
||||
{
|
||||
char *fieldp = blk + field->offset;
|
||||
+ uint64_t num = *(uint64_t *)val;
|
||||
|
||||
if (field->flags & LGFS2_MFF_UUID) {
|
||||
memcpy(fieldp, val, 16);
|
||||
@@ -959,16 +960,16 @@ int lgfs2_field_assign(char *blk, const struct lgfs2_metafield *field, const voi
|
||||
|
||||
switch(field->length) {
|
||||
case sizeof(uint8_t):
|
||||
- *fieldp = *(uint8_t *)val;
|
||||
+ *fieldp = (uint8_t)num;
|
||||
return 0;
|
||||
case sizeof(uint16_t):
|
||||
- *(uint16_t *)fieldp = cpu_to_be16(*(uint16_t *)val);
|
||||
+ *(uint16_t *)fieldp = cpu_to_be16((uint16_t)num);
|
||||
return 0;
|
||||
case sizeof(uint32_t):
|
||||
- *(uint32_t *)fieldp = cpu_to_be32(*(uint32_t *)val);
|
||||
+ *(uint32_t *)fieldp = cpu_to_be32((uint32_t)num);
|
||||
return 0;
|
||||
case sizeof(uint64_t):
|
||||
- *(uint64_t *)fieldp = cpu_to_be64(*(uint64_t *)val);
|
||||
+ *(uint64_t *)fieldp = cpu_to_be64((uint64_t)num);
|
||||
return 0;
|
||||
default:
|
||||
/* Will never happen */
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
Name: gfs2-utils
|
||||
Version: 3.2.0
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: Global Filesystem Utilities
|
||||
|
||||
License: GPLv2+ and LGPLv2+
|
||||
URL: https://pagure.io/gfs2-utils
|
||||
Source0: https://releases.pagure.org/gfs2-utils/gfs2-utils-%{version}.tar.gz
|
||||
|
||||
Patch0001: 0001-libgfs2-Fix-pointer-cast-byte-order-issue.patch
|
||||
|
||||
BuildRequires: ncurses-devel kernel-headers automake libtool zlib-devel gettext-devel
|
||||
BuildRequires: bison flex libblkid-devel libuuid-devel check-devel
|
||||
|
||||
@ -51,6 +53,9 @@ make -C gfs2 install DESTDIR=%{buildroot}
|
||||
%exclude %{_mandir}/man8/gfs2_lockcapture.8.gz
|
||||
|
||||
%changelog
|
||||
* Thu Oct 19 2023 liyuanyuan <liyuanyuan@xfusion.com> - 3.2.0-6
|
||||
- libgfs2: Fix pointer cast byte order issue
|
||||
|
||||
* Tue Jan 21 2020 daiqianwen <daiqianwen@huawei.com> - 3.2.0-5
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user