Blame SOURCES/e2fsprogs-1.42.9-fix-endian-handling-of-ext3_extent_header.patch

ec15cf
[PATCH 2/6] e2fsprogs: fix endian handling of ext3_extent_header
ec15cf
ec15cf
This turned up when trying to resize a filesystem containing
ec15cf
a file with many extents on PPC64.
ec15cf
ec15cf
Fix all locations where ext3_extent_header members aren't
ec15cf
handled in an endian-safe manner.
ec15cf
ec15cf
(Note: inline data portion removed for rhel7 application)
ec15cf
ec15cf
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
ec15cf
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
ec15cf
---
ec15cf
 lib/ext2fs/ext3_extents.h |   15 ++++++++++-----
ec15cf
 2 files changed, 11 insertions(+), 6 deletions(-)
ec15cf
ec15cf
diff --git a/lib/ext2fs/ext3_extents.h b/lib/ext2fs/ext3_extents.h
ec15cf
index 4163436..a18d705 100644
ec15cf
--- a/lib/ext2fs/ext3_extents.h
ec15cf
+++ b/lib/ext2fs/ext3_extents.h
ec15cf
@@ -106,15 +106,20 @@ struct ext3_ext_path {
ec15cf
 	((struct ext3_extent_idx *) (((char *) (__hdr__)) +	\
ec15cf
 				     sizeof(struct ext3_extent_header)))
ec15cf
 #define EXT_HAS_FREE_INDEX(__path__) \
ec15cf
-	((__path__)->p_hdr->eh_entries < (__path__)->p_hdr->eh_max)
ec15cf
+	(ext2fs_le16_to_cpu((__path__)->p_hdr->eh_entries) < \
ec15cf
+	 ext2fs_le16_to_cpu((__path__)->p_hdr->eh_max))
ec15cf
 #define EXT_LAST_EXTENT(__hdr__) \
ec15cf
-	(EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->eh_entries - 1)
ec15cf
+	(EXT_FIRST_EXTENT((__hdr__)) + \
ec15cf
+	ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
ec15cf
 #define EXT_LAST_INDEX(__hdr__) \
ec15cf
-	(EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->eh_entries - 1)
ec15cf
+	(EXT_FIRST_INDEX((__hdr__)) + \
ec15cf
+	ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
ec15cf
 #define EXT_MAX_EXTENT(__hdr__) \
ec15cf
-	(EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->eh_max - 1)
ec15cf
+	(EXT_FIRST_EXTENT((__hdr__)) + \
ec15cf
+	ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
ec15cf
 #define EXT_MAX_INDEX(__hdr__) \
ec15cf
-	(EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->eh_max - 1)
ec15cf
+	(EXT_FIRST_INDEX((__hdr__)) + \
ec15cf
+	ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
ec15cf
 
ec15cf
 #endif /* _LINUX_EXT3_EXTENTS */