diff options
Diffstat (limited to 'ext/fileinfo/libmagic/apprentice.c')
| -rw-r--r-- | ext/fileinfo/libmagic/apprentice.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index d4e0e889d5..5e7b9cffdd 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -1921,6 +1921,16 @@ internal_loaded: goto error1; } + /* php_magic_database is a const, performing writes will segfault. This is for big-endian + machines only, PPC and Sparc specifically. Consider static variable or MINIT in + future. */ + if (needsbyteswap && fn == NULL) { + mm = emalloc(sizeof(php_magic_database)); + mm = memcpy(mm, php_magic_database, sizeof(php_magic_database)); + *magicp = mm; + ret = 1; + } + if (fn == NULL) { *nmagicp = (sizeof(php_magic_database) / sizeof(struct magic)); } else { |
