Fix issues in nbdkit-data-plugin on 32 bit platforms.
This commit is contained in:
parent
5f0a7b31b4
commit
42e0d28d9a
62
0001-data-Fix-issues-on-32-bit.patch
Normal file
62
0001-data-Fix-issues-on-32-bit.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From fe6538aafe5f8d6fc6b90ae8f6d3686c711288fd Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Mon, 23 Aug 2021 10:34:53 +0100
|
||||
Subject: [PATCH] data: Fix issues on 32 bit
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Commit 9352ad00e3 ("data: New functions new_node/get_node with simpler
|
||||
usage") added a new expr() function to let you construct expressions.
|
||||
However it uses varargs so callers have to be strict about the types
|
||||
of the parameters, and the compiler cannot verify this.
|
||||
|
||||
When creating EXPR_FILL the parameters are uint8_t, uint64_t, where
|
||||
varargs always promotes uint8_t to int. We called it in a few places
|
||||
with incorrect types. The error showed up when compiling on i686, but
|
||||
actually we were very lucky this did not manifest on 64 bit platforms
|
||||
too. It only worked because of how x86-64 ABI passes some arguments
|
||||
in registers so that int is passed in a 64 bit register. On a 64 bit
|
||||
platform that uses the stack it could have failed.
|
||||
|
||||
Use casts as appropriate. Strongly typed qualified unions à la OCaml
|
||||
would help here!
|
||||
|
||||
Fixes: commit 9352ad00e3e1fff679f4eabb2208bfa1e1443a29
|
||||
---
|
||||
plugins/data/format.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/plugins/data/format.c b/plugins/data/format.c
|
||||
index f1b4219e..60b73ef9 100644
|
||||
--- a/plugins/data/format.c
|
||||
+++ b/plugins/data/format.c
|
||||
@@ -1358,14 +1358,14 @@ optimize_ast (node_id root, node_id *root_rtn)
|
||||
*/
|
||||
if (get_node (root).string.size > 1) {
|
||||
const string s = get_node (root).string;
|
||||
- uint64_t b = s.ptr[0];
|
||||
+ uint8_t b = s.ptr[0];
|
||||
|
||||
for (i = 1; i < s.size; ++i)
|
||||
if (s.ptr[i] != b)
|
||||
break;
|
||||
|
||||
if (i == s.size) {
|
||||
- *root_rtn = new_node (expr (EXPR_FILL, b, s.size));
|
||||
+ *root_rtn = new_node (expr (EXPR_FILL, b, (uint64_t) s.size));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1485,7 +1485,7 @@ exprs_can_combine (expr_t e0, expr_t e1, node_id *id_rtn)
|
||||
switch (e1.t) {
|
||||
case EXPR_BYTE: /* byte byte => fill | string */
|
||||
if (e0.b == e1.b) {
|
||||
- *id_rtn = new_node (expr (EXPR_FILL, e0.b, 2));
|
||||
+ *id_rtn = new_node (expr (EXPR_FILL, e0.b, UINT64_C(2)));
|
||||
}
|
||||
else {
|
||||
if (string_append (&s, e0.b) == -1 ||
|
||||
--
|
||||
2.32.0
|
||||
|
@ -72,6 +72,9 @@ Source2: libguestfs.keyring
|
||||
# Maintainer script which helps with handling patches.
|
||||
Source3: copy-patches.sh
|
||||
|
||||
# Fix issues in nbdkit-data-plugin on 32 bit platforms.
|
||||
Patch1: 0001-data-Fix-issues-on-32-bit.patch
|
||||
|
||||
BuildRequires: make
|
||||
%if 0%{patches_touch_autotools}
|
||||
BuildRequires: autoconf, automake, libtool
|
||||
|
Loading…
Reference in New Issue
Block a user