Author: blueswirl Date: 2009-02-08 16:45:15 +0100 (Sun, 08 Feb 2009) New Revision: 450
Modified: openbios-devel/fs/grubfs/fsys_iso9660.c openbios-devel/fs/grubfs/iso9660.h Log: Fix endianess bug in Rock Ridge extensions
Modified: openbios-devel/fs/grubfs/fsys_iso9660.c =================================================================== --- openbios-devel/fs/grubfs/fsys_iso9660.c 2009-02-08 12:22:04 UTC (rev 449) +++ openbios-devel/fs/grubfs/fsys_iso9660.c 2009-02-08 15:45:15 UTC (rev 450) @@ -192,16 +192,16 @@ rr_ptr.rr->signature >> 8); #endif } - else if (rr_ptr.rr->signature == RRMAGIC('R', 'R') + else if (CHECK2(&rr_ptr.rr->signature, 'R', 'R') && rr_ptr.rr->len >= 5) rr_flag &= rr_ptr.rr->u.rr.flags.ENDIAN; - else if (rr_ptr.rr->signature == RRMAGIC('N', 'M')) + else if (CHECK2(&rr_ptr.rr->signature, 'N', 'M')) { name = (char *)rr_ptr.rr->u.nm.name; name_len = rr_ptr.rr->len - 5; rr_flag &= ~RR_FLAG_NM; } - else if (rr_ptr.rr->signature == RRMAGIC('P', 'X') + else if (CHECK2(&rr_ptr.rr->signature, 'P', 'X') && rr_ptr.rr->len >= 36) { file_type = ((rr_ptr.rr->u.px.mode.ENDIAN & POSIX_S_IFMT) @@ -212,7 +212,7 @@ ? ISO_DIRECTORY : ISO_OTHER)); rr_flag &= ~RR_FLAG_PX; } - else if (rr_ptr.rr->signature == RRMAGIC('C', 'E') + else if (CHECK2(&rr_ptr.rr->signature, 'C', 'E') && rr_ptr.rr->len >= 28) ce_ptr = rr_ptr.rr; if (!rr_flag)
Modified: openbios-devel/fs/grubfs/iso9660.h =================================================================== --- openbios-devel/fs/grubfs/iso9660.h 2009-02-08 12:22:04 UTC (rev 449) +++ openbios-devel/fs/grubfs/iso9660.h 2009-02-08 15:45:15 UTC (rev 450) @@ -157,10 +157,9 @@ int i; } RR_ptr_t;
-#define RRMAGIC(c1, c2) ((c1)|(c2) << 8) - -#define CHECK2(ptr, c1, c2) \ - (*(ptr) == (c1) && *(ptr + 1) == (c2)) +#define CHECK2(ptr, c1, c2) \ + (*(unsigned char *)(ptr) == (c1) && \ + *((unsigned char *)(ptr) + 1) == (c2)) #define CHECK4(ptr, c1, c2, c3, c4) \ (*(unsigned char *)(ptr) == (c1) && \ *((unsigned char *)(ptr) + 1) == (c2) && \