diff options
author | H. Peter Anvin <hpa@zytor.com> | 2013-04-02 20:43:25 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2013-04-02 20:43:25 -0700 |
commit | 01408738c1aafbcf669b289b85795c3aa9dbec2a (patch) | |
tree | f7bf6bfcd3eb49375dd1141e99f9d9b23e794545 | |
parent | 44a33fd5e9dbc7d3a789ac9ec912b7a873adaab0 (diff) | |
download | syslinux-01408738c1aafbcf669b289b85795c3aa9dbec2a.tar.gz syslinux-01408738c1aafbcf669b289b85795c3aa9dbec2a.tar.xz syslinux-01408738c1aafbcf669b289b85795c3aa9dbec2a.zip |
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. ]
-rw-r--r-- | core/fs/iso9660/susp_rr.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/core/fs/iso9660/susp_rr.c b/core/fs/iso9660/susp_rr.c index 3d99b749..e758586f 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; |