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

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