File libcdio-LE-BE-sizemismatch.patch of Package libcdio.24379
From a4155f014c640e6896a41205a0f997be8db33808 Mon Sep 17 00:00:00 2001
From: Pete Batard <pete@akeo.ie>
Date: Sun, 27 May 2018 22:27:27 +0100
Subject: Set from_723 and from_733 to return the little-endian value always
* And silence the warning in case of little-endian and big-endian mismatch
* Also introduce a from_723_with_err() that can be used to report mismatch
if needed
---
include/cdio/bytesex.h | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/include/cdio/bytesex.h b/include/cdio/bytesex.h
index 0ec9246..c66ed80 100644
--- a/include/cdio/bytesex.h
+++ b/include/cdio/bytesex.h
@@ -171,9 +171,20 @@ to_723(uint16_t i)
static CDIO_INLINE uint16_t
from_723 (uint32_t p)
{
- if (uint32_swap_le_be (p) != p)
- cdio_warn ("from_723: broken byte order");
+ uint8_t *u = (uint8_t *) &p;
+ /* Return the little-endian part always, to handle non-specs-compliant images */
+ return (u[0] | (u[1] << 8));
+}
+static CDIO_INLINE uint16_t
+from_723_with_err (uint32_t p, bool *err)
+{
+ if (uint32_swap_le_be (p) != p) {
+ cdio_warn ("from_723: broken byte order");
+ *err = true;
+ } else {
+ *err = false;
+ }
return (0xFFFF & p);
}
@@ -200,10 +211,9 @@ to_733(uint32_t i)
static CDIO_INLINE uint32_t
from_733 (uint64_t p)
{
- if (uint64_swap_le_be (p) != p)
- cdio_warn ("from_733: broken byte order");
-
- return (UINT32_C(0xFFFFFFFF) & p);
+ uint8_t *u = (uint8_t *) &p;
+ /* Return the little-endian part always, to handle non-specs-compliant images */
+ return (u[0] | (u[1] << 8) | (u[2] << 16) | (u[3] << 24));
}
static CDIO_INLINE uint32_t
--
cgit v1.0-41-gc330