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

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