From 21cd3b718a2311671ef283759b6d3723fa9db232 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 2 Feb 2023 00:38:13 +0100 Subject: Avoid unaligned memory accesses --- isofs/iso9660.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'isofs') diff --git a/isofs/iso9660.h b/isofs/iso9660.h index 2fd8cc2b..be96b8f5 100644 --- a/isofs/iso9660.h +++ b/isofs/iso9660.h @@ -102,24 +102,12 @@ struct dirrect static inline unsigned int isonum_733 (unsigned char *addr) { -#if BYTE_ORDER == LITTLE_ENDIAN - return *(unsigned int *)addr; -#elif BYTE_ORDER == BIG_ENDIAN - return *(unsigned int *)(addr + 4); -#else - return - addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24); -#endif + return addr[0] | (addr[1] << 8) | (addr[2] << 16) | + (((unsigned int) addr[3]) << 24); } static inline unsigned int isonum_723 (unsigned char *addr) { -#if BYTE_ORDER == LITTLE_ENDIAN - return *(unsigned short *)addr; -#elif BYTE_ORDER == BIG_ENDIAN - return *(unsigned short *)addr + 2; -#else return addr[0] | (addr[1] << 8); -#endif } -- cgit v1.2.3