Skip to content

Commit e865c64

Browse files
committed
WIP
1 parent a79c651 commit e865c64

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ext/phar/tar.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,13 +1240,15 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
12401240
return EOF;
12411241
}
12421242
#ifdef WORDS_BIGENDIAN
1243-
# define PHAR_SET_32(var, buffer) \
1244-
*(uint32_t *)(var) = (((((unsigned char*)&(buffer))[3]) << 24) \
1245-
| ((((unsigned char*)&(buffer))[2]) << 16) \
1246-
| ((((unsigned char*)&(buffer))[1]) << 8) \
1247-
| (((unsigned char*)&(buffer))[0]))
1243+
# define PHAR_SET_32(destination, source) do { \
1244+
uint32_t swapped = (((((unsigned char*)&(source))[3]) << 24) \
1245+
| ((((unsigned char*)&(source))[2]) << 16) \
1246+
| ((((unsigned char*)&(source))[1]) << 8) \
1247+
| (((unsigned char*)&(source))[0])); \
1248+
memcpy(destination, &swapped, 4); \
1249+
} while (0);
12481250
#else
1249-
# define PHAR_SET_32(var, buffer) *(uint32_t *)(var) = (uint32_t) (buffer)
1251+
# define PHAR_SET_32(destination, source) memcpy(destination, &source, 4)
12501252
#endif
12511253
PHAR_SET_32(sigbuf, phar->sig_flags);
12521254
PHAR_SET_32(sigbuf + 4, signature_length);

0 commit comments

Comments
 (0)