scottmac Wed Oct 22 14:15:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/fileinfo/libmagic apprentice.c Log: MFH: When using the internal database and there is an error it could try free some invalid things. This was causing a bus error on ppc. http://cvs.php.net/viewvc.cgi/php-src/ext/fileinfo/libmagic/apprentice.c?r1=1.7.2.9&r2=1.7.2.10&diff_format=u Index: php-src/ext/fileinfo/libmagic/apprentice.c diff -u php-src/ext/fileinfo/libmagic/apprentice.c:1.7.2.9 php-src/ext/fileinfo/libmagic/apprentice.c:1.7.2.10 --- php-src/ext/fileinfo/libmagic/apprentice.c:1.7.2.9 Mon Oct 20 23:36:14 2008 +++ php-src/ext/fileinfo/libmagic/apprentice.c Wed Oct 22 14:15:47 2008 @@ -1842,6 +1842,9 @@ /* * handle a compiled file. + * return -1 = error + * return 1 = memory structure you can free + * return 3 = bundled library from PHP */ private int apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, @@ -1853,7 +1856,7 @@ char *dbname = NULL; void *mm = NULL; int ret = 0; - php_stream *stream; + php_stream *stream = NULL; php_stream_statbuf st; @@ -1908,12 +1911,15 @@ goto error1; } needsbyteswap = 1; - } else + } else { needsbyteswap = 0; + } + if (needsbyteswap) version = swap4(ptr[1]); else version = ptr[1]; + if (version != VERSIONNO) { file_error(ms, 0, "File %d.%d supports only %d version magic " "files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel, @@ -1953,14 +1959,17 @@ if (stream) { php_stream_close(stream); } - if (mm) { + + if (mm && ret == 1) { efree(mm); } else { *magicp = NULL; *nmagicp = 0; } error2: - efree(dbname); + if (dbname) { + efree(dbname); + } return -1; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php