[syslinux:rockridge] iso9660: read littleendian ISO 9660/ SUSP numbers

syslinux-bot for H. Peter Anvin hpa at zytor.com
Tue Apr 2 20:45:06 PDT 2013


Commit-ID:  01408738c1aafbcf669b289b85795c3aa9dbec2a
Gitweb:     http://www.syslinux.org/commit/01408738c1aafbcf669b289b85795c3aa9dbec2a
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 2 Apr 2013 20:43:25 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 2 Apr 2013 20:43:25 -0700

iso9660: read littleendian ISO 9660/SUSP numbers

Attached is a patch which switches susp_rr.c from reading the
big-endian ISO 9660 and SUSP numbers to reading the little-endian
ones.

Tested within libisofs on my collection of ISO images.

[ hpa: more mastering programs are known which botch the bigendian
  information than the littleendian information, so most systems only
  read the littleendian info regardless of the native byte order. ]

---
 core/fs/iso9660/susp_rr.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/core/fs/iso9660/susp_rr.c b/core/fs/iso9660/susp_rr.c
index 3d99b74..e758586 100644
--- a/core/fs/iso9660/susp_rr.c
+++ b/core/fs/iso9660/susp_rr.c
@@ -99,16 +99,13 @@ static int susp_rr_is_out_of_mem(void *pt)
 }
 
 
-/* XXX: Is there already a reader for 32-bit MSB or LSB in the syslinux code ?
-	(iso9660.c seems to flatly assume that it runs on little-endian int.)
-*/
-static uint32_t susp_rr_read_msb(uint8_t *buf, int bytes)
+static uint32_t susp_rr_read_lsb(uint8_t *buf, int bytes)
 {
     int i;
     uint32_t ret = 0;
 
     for (i = 0; i < bytes; i++) {
-	ret += ((uint32_t) buf[bytes - i - 1]) << (i * 8);
+	ret += ((uint32_t) buf[i]) << (i * 8);
     }
     return ret;
 }
@@ -277,9 +274,9 @@ static int susp_rr_iterate(struct susp_rr_iter *iter, char **pos_pt)
 	}
 	/* Register address data of next Continuation Area */
 	u_entry = (uint8_t *) entries;
-	iter->next_lba = susp_rr_read_msb(u_entry + 8, 4);
-	iter->next_offset = susp_rr_read_msb(u_entry + 16, 4);
-	iter->next_length = susp_rr_read_msb(u_entry + 24, 4);
+	iter->next_lba = susp_rr_read_lsb(u_entry + 4, 4);
+	iter->next_offset = susp_rr_read_lsb(u_entry + 12, 4);
+	iter->next_length = susp_rr_read_lsb(u_entry + 20, 4);
     }
 
     *pos_pt = entries;
@@ -464,7 +461,7 @@ int susp_rr_check_signatures(struct fs_info *fs, int flag)
 #endif /* Isolinux_rockridge_in_libisofS */
 
     /* Obtain first dir_rec of root directory */
-    lba = susp_rr_read_msb(((uint8_t *) &(sbi->root)) + 6, 4);
+    lba = susp_rr_read_lsb(((uint8_t *) &(sbi->root)) + 2, 4);
     dir_rec = (char *) get_cache(fs->fs_dev, lba);
     if (dir_rec == NULL)
 	goto no_susp;


More information about the Syslinux-commits mailing list