Compare commits

..
2 Commits
Author SHA1 Message Date
Johannes Schlüter be8864cc22 PHP 5.3.9 (re-tag after version no. fix) 2012-01-10 13:33:01 +00:00
Johannes Schlüter d0cc4a1cfc PHP 5.3.9 2012-01-10 11:25:30 +00:00
316 changed files with 86023 additions and 126769 deletions

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
define ____executor_globals
if basic_functions_module.zts
set $tsrm_ls = ts_resource_ex(0, 0)
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
set $eg = ((zend_executor_globals) (*((void ***) $tsrm_ls))[executor_globals_id-1])
set $cg = ((zend_compiler_globals) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
else
set $eg = executor_globals
set $cg = compiler_globals
-173
View File
@@ -1,173 +0,0 @@
ext/mysqlnd/mysqlnd.h ident
ext/simplexml/simplexml.c ident
ext/iconv/php_iconv.h ident
ext/posix/posix.c ident
ext/recode/recode.c ident
ext/skeleton/create_stubs ident
ext/phar/phar/pharcommand.inc ident
ext/phar/phar.c ident
ext/sysvmsg/sysvmsg.c ident
ext/enchant/enchant.c ident
ext/reflection/php_reflection.c ident
ext/oci8/oci8.c ident
ext/dba/libinifile/inifile.c ident
ext/dba/libflatfile/flatfile.c ident
ext/dba/libcdb/cdb_make.c ident
ext/dba/libcdb/cdb.c ident
ext/filter/filter.c ident
README.input_filter ident
run-tests.php ident
sapi/nsapi/nsapi.c ident
sapi/continuity/capi.c ident
Zend/RFCs/002.txt ident
Zend/RFCs/003.txt ident
NEWS merge=NEWS
/ext/bz2/tests/005.phpt -crlf
/ext/dom/tests/dom005.phpt -crlf
/ext/dom/tests/DOMImplementation_createDocumentType_basic.phpt -crlf
/ext/ereg/tests/009.phpt -crlf
/ext/iconv/tests/eucjp2sjis.phpt -crlf
/ext/iconv/tests/eucjp2utf8.phpt -crlf
/ext/iconv/tests/iconv_stream_filter_delimiter.phpt -crlf
/ext/iconv/tests/iconv_stream_filter.phpt -crlf
/ext/mbstring/tests/mb_split-compat-01.phpt -crlf
/ext/phar/tests/005.phpt -crlf
/ext/phar/tests/phar_commitwrite.phpt -crlf
/ext/phar/tests/phar_create_in_cwd.phpt -crlf
/ext/phar/tests/phar_mount.phpt -crlf
/ext/reflection/tests/009.phpt -crlf
/ext/reflection/tests/025.phpt -crlf
/ext/standard/tests/general_functions/highlight_heredoc.phpt -crlf
/ext/standard/tests/general_functions/parse_ini_file.phpt -crlf
/ext/standard/tests/general_functions/parse_ini_string_002.phpt -crlf
/ext/standard/tests/strings/006.phpt -crlf
/ext/standard/tests/strings/addslashes_variation2.phpt -crlf
/ext/standard/tests/strings/addslashes_variation3.phpt -crlf
/ext/standard/tests/strings/bug21453.phpt -crlf
/ext/standard/tests/strings/chop_variation3.phpt -crlf
/ext/standard/tests/strings/chunk_split_variation11.phpt -crlf
/ext/standard/tests/strings/chunk_split_variation12.phpt -crlf
/ext/standard/tests/strings/chunk_split_variation4.phpt -crlf
/ext/standard/tests/strings/crc32_variation2.phpt -crlf
/ext/standard/tests/strings/crc32_variation3.phpt -crlf
/ext/standard/tests/strings/crc32_variation4.phpt -crlf
/ext/standard/tests/strings/highlight_file.phpt -crlf
/ext/standard/tests/strings/htmlentities_html4.phpt -crlf
/ext/standard/tests/strings/lcfirst.phpt -crlf
/ext/standard/tests/strings/ltrim.phpt -crlf
/ext/standard/tests/strings/nl2br_variation2.phpt -crlf
/ext/standard/tests/strings/php_strip_whitespace.phpt -crlf
/ext/standard/tests/strings/rtrim.phpt -crlf
/ext/standard/tests/strings/sprintf_f_2.phpt -crlf
/ext/standard/tests/strings/sprintf_variation15.phpt -crlf
/ext/standard/tests/strings/strcspn_variation6.phpt -crlf
/ext/standard/tests/strings/strcspn_variation7.phpt -crlf
/ext/standard/tests/strings/strcspn_variation8.phpt -crlf
/ext/standard/tests/strings/stripos_variation1.phpt -crlf
/ext/standard/tests/strings/stripos_variation3.phpt -crlf
/ext/standard/tests/strings/stripos_variation4.phpt -crlf
/ext/standard/tests/strings/stripos_variation5.phpt -crlf
/ext/standard/tests/strings/stripos_variation6.phpt -crlf
/ext/standard/tests/strings/stripslashes_variation2.phpt -crlf
/ext/standard/tests/strings/stripslashes_variation3.phpt -crlf
/ext/standard/tests/strings/stripslashes_variation4.phpt -crlf
/ext/standard/tests/strings/stripslashes_variation5.phpt -crlf
/ext/standard/tests/strings/str_ireplace.phpt -crlf
/ext/standard/tests/strings/strnatcmp_basic.phpt -crlf
/ext/standard/tests/strings/strncasecmp_variation9.phpt -crlf
/ext/standard/tests/strings/strpos.phpt -crlf
/ext/standard/tests/strings/strrchr_variation1.phpt -crlf
/ext/standard/tests/strings/strrchr_variation2.phpt -crlf
/ext/standard/tests/strings/strrchr_variation3.phpt -crlf
/ext/standard/tests/strings/strrchr_variation4.phpt -crlf
/ext/standard/tests/strings/strrchr_variation6.phpt -crlf
/ext/standard/tests/strings/strrchr_variation7.phpt -crlf
/ext/standard/tests/strings/str_replace.phpt -crlf
/ext/standard/tests/strings/strrev_variation3.phpt -crlf
/ext/standard/tests/strings/strrev_variation4.phpt -crlf
/ext/standard/tests/strings/strripos_variation1.phpt -crlf
/ext/standard/tests/strings/strripos_variation2.phpt -crlf
/ext/standard/tests/strings/strripos_variation3.phpt -crlf
/ext/standard/tests/strings/strripos_variation4.phpt -crlf
/ext/standard/tests/strings/strripos_variation5.phpt -crlf
/ext/standard/tests/strings/strrpos_variation1.phpt -crlf
/ext/standard/tests/strings/strrpos_variation2.phpt -crlf
/ext/standard/tests/strings/strrpos_variation3.phpt -crlf
/ext/standard/tests/strings/strrpos_variation4.phpt -crlf
/ext/standard/tests/strings/strrpos_variation5.phpt -crlf
/ext/standard/tests/strings/strrpos_variation6.phpt -crlf
/ext/standard/tests/strings/strspn_variation5.phpt -crlf
/ext/standard/tests/strings/strspn_variation6.phpt -crlf
/ext/standard/tests/strings/strspn_variation7.phpt -crlf
/ext/standard/tests/strings/strspn_variation8.phpt -crlf
/ext/standard/tests/strings/strstr.phpt -crlf
/ext/standard/tests/strings/strtok_variation1.phpt -crlf
/ext/standard/tests/strings/strtok_variation3.phpt -crlf
/ext/standard/tests/strings/strtr_variation1.phpt -crlf
/ext/standard/tests/strings/strtr_variation2.phpt -crlf
/ext/standard/tests/strings/str_word_count.phpt -crlf
/ext/standard/tests/strings/trim1.phpt -crlf
/ext/standard/tests/strings/ucfirst.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation10.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation12.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation16.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation18.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation4.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation6.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation7.phpt -crlf
/ext/standard/tests/strings/vfprintf_variation8.phpt -crlf
/ext/standard/tests/strings/vprintf_variation10.phpt -crlf
/ext/standard/tests/strings/vprintf_variation12.phpt -crlf
/ext/standard/tests/strings/vprintf_variation14.phpt -crlf
/ext/standard/tests/strings/vprintf_variation18.phpt -crlf
/ext/standard/tests/strings/vprintf_variation4.phpt -crlf
/ext/standard/tests/strings/vprintf_variation6.phpt -crlf
/ext/standard/tests/strings/vprintf_variation7.phpt -crlf
/ext/standard/tests/strings/vprintf_variation8.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation10.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation12.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation14.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation16.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation4.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation6.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation7.phpt -crlf
/ext/standard/tests/strings/vsprintf_variation8.phpt -crlf
/ext/standard/tests/strings/wordwrap.phpt -crlf
/ext/tidy/tests/010.phpt -crlf
/ext/tidy/tests/012.phpt -crlf
/ext/tidy/tests/025.phpt -crlf
/ext/tidy/tests/030.phpt -crlf
/ext/tokenizer/tests/bug26463.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation12.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation13.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation14.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation15.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation16.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation17.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation18.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation19.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation4.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation5.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation6.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation7.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation8.phpt -crlf
/ext/tokenizer/tests/token_get_all_variation9.phpt -crlf
/ext/xml/tests/bug26614_libxml.phpt -crlf
/ext/xmlwriter/tests/004.phpt -crlf
/ext/xmlwriter/tests/OO_004.phpt -crlf
/ext/zlib/tests/005.phpt -crlf
/ext/zlib/tests/gzfile_basic2.phpt -crlf
/ext/zlib/tests/gzfile_basic.phpt -crlf
/ext/zlib/tests/gzfilegzreadfile.phpt -crlf
/ext/zlib/tests/readgzfile_basic2.phpt -crlf
/ext/zlib/tests/readgzfile_basic.phpt -crlf
/sapi/cli/tests/014.phpt -crlf
/tests/run-test/test010.phpt -crlf
/Zend/tests/bug35655.phpt -crlf
/Zend/tests/bug48930.phpt -crlf
/Zend/tests/bug61095.phpt -crlf
/Zend/tests/heredoc_017.phpt -crlf
/Zend/tests/heredoc_018.phpt -crlf
/Zend/tests/nowdoc_013.phpt -crlf
/Zend/tests/nowdoc_014.phpt -crlf
/Zend/tests/nowdoc_015.phpt -crlf
-254
View File
@@ -1,254 +0,0 @@
# General Ignores
*~
.#*
*.
*.slo
*.mk
*.mem
*.gcda
*.gcno
*.la
*.lo
*.o
*.a
*.ncb
*.opt
*.plg
*swp
*.patch
*.tgz
*.tar.gz
*.tar.bz2
.FBCIndex
.FBCLockFolder
.deps
.libs
phpt.*
core
dynlib.m4
Debug
Debug_TS
Makefile
Makefile.fragments
Makefile.objects
Release
Release_TS
Release_TSDbg
Release_TS_inline
Release_inline
ZendEngine1
_libs
acconfig.h
aclocal.m4
autom4te.cache
bsd_converted
buildconf.stamp
buildmk.stamp
confdefs.h
config.h
config.guess
config.cache
config.h.in
config.log
config.nice
config.nice.bat
config.status
config.sub
config_vars.mk
configuration-parser.c
configuration-parser.h
configuration-parser.output
configuration-scanner.c
configure
configure.bat
configure.js
conftest
conftest.c
debug.log
diff
generated_lists
include
install-sh
internal_functions.c
lcov_data
lcov_html
libs
libtool
meta_cc
meta_ccld
missing
mkinstalldirs
modules
php
php-*.tar.gz
php5.spec
php_lcov.info
php_test_results_*.txt
php_version.h
results.txt
shlibtool
stamp-h
test.php3
tmp-php.ini
want_dependencies
x64
stamp-h.in
scan_makefile_in.awk
TSRM/tsrm_config.h
Zend/zend_config.h
Zend/zend_ini_parser.c
Zend/zend_ini_parser.h
Zend/zend_ini_parser.output
Zend/zend_language_parser.c
Zend/zend_language_parser.h
Zend/zend_language_parser.output
ext/date/lib/timelib_config.h
ext/iconv/php_iconv_aliased_libiconv.h
ext/phar/phar.php
main/php_config.h
main/php_config.h.in
# Test specific Ignores
tests/*/*.diff
tests/*/*.out
tests/*/*.php
tests/*/*.exp
tests/*/*.log
tests/*/*.sh
*/tests/*.diff
*/tests/*.out
*/tests/*.php
*/tests/*.exp
*/tests/*.log
*/tests/*.sh
*/tests/*/*.diff
*/tests/*/*.out
*/tests/*/*.php
*/tests/*/*.exp
*/tests/*/*.log
*/tests/*/*.sh
*/*/tests/*.diff
*/*/tests/*.out
*/*/tests/*.php
*/*/tests/*.exp
*/*/tests/*.log
*/*/tests/*.sh
*/*/tests/*/*.diff
*/*/tests/*/*.out
*/*/tests/*/*.php
*/*/tests/*/*.exp
*/*/tests/*/*.log
*/*/tests/*/*.sh
# Extension specifc ignores
ext/*/configure.in
ext/*/ltmain.sh
ext/*/libs.mk
ext/*/build
ext/*/scan_makefile_in.awk
ext/*/Makefile.global
ext/*/acinclude.m4
ext/*/config.sub
# Extension specific
ext/iconv/scan_makefile_in.awk
ext/iconv/php_have_bsd_iconv.h
ext/iconv/php_have_ibm_iconv.h
ext/iconv/php_have_libiconv.h
ext/iconv/php_php_iconv_h_path.h
ext/iconv/php_have_glibc_iconv.h
ext/iconv/php_php_iconv_impl.h
ext/iconv/php_have_iconv.h
ext/iconv/php_iconv_supports_errno.h
ext/mbstring/libmbfl/Makefile.in
ext/mbstring/libmbfl/autoscan.log
ext/mbstring/libmbfl/config.sub
ext/mbstring/libmbfl/depcomp
ext/mbstring/libmbfl/ltmain.sh
ext/mbstring/libmbfl/stamp-h1
ext/mbstring/libmbfl/*.dll
ext/mbstring/libmbfl/*.lib
ext/mbstring/libmbfl/*.RES
ext/mbstring/libmbfl/*.res
ext/mbstring/libmbfl/*.obj
ext/mbstring/libmbfl/*.tds
ext/mbstring/libmbfl/filters/Makefile.in
ext/mbstring/libmbfl/mbfl/Makefile.in
ext/mbstring/libmbfl/mbfl/EastAsianWidth.txt
ext/mbstring/libmbfl/nls/Makefile.in
ext/mssql/#*#
ext/mssql/Makefile.global
ext/mssql/acinclude.m4
ext/mssql/config.sub
ext/mssql/configure.in
ext/mssql/ltmain.sh
ext/mysql/weztest.sqlite
ext/oci8/tests/*.tmp
ext/oci8/tests/*.vglog
ext/pdo/conftest*
ext/pdo/tests/*.db
ext/pdo/tests/*.tmp
ext/pdo_firebird/conftest*
ext/pdo_mysql/conftest*
ext/pdo_mysql/tests/*.db
ext/pdo_mysql/tests/*.tmp
ext/pdo_oci/conftest*
ext/pdo_odbc/tests/*.db
ext/pdo_odbc/tests/*.tmp
ext/pdo_odbc/tests/*.mdb
ext/pdo_pgsql/conftest*
ext/pdo_pgsql/tests/*.db
ext/pdo_pgsql/tests/*.tmp
ext/pdo_sqlite/conftest*
ext/pdo_sqlite/sqlite3.h
ext/pdo_sqlite/tests/*.db
ext/pdo_sqlite/tests/*.tmp
ext/phar/phar.phar
ext/pspell/tests/*.tmp
ext/reflection/xml
ext/reflection/html
ext/reflection/spl.chm
ext/simplexml/examples/security.new.xml
ext/spl/examples/.htaccess
ext/spl/examples/*.phps
ext/sqlite/weztest.sqlite
ext/sqlite/libsqlite/src/sqlite.h
ext/sqlite/libsqlite/src/parse.out
ext/sqlite/libsqlite/src/libsqlite.dsw
ext/sqlite3/tests/phpsql*
ext/sqlite3/tests/*.db
ext/sqlite3/tests/*.tmp
ext/standard/tests/misc/*.txt
ext/standard/tests/strings/*.txt
main/build-defs.h
main/internal_functions_cli.c
main/config.w32.h
main/stamp-h1
main/streams/build-defs.h
main/streams/stamp-h1
pear/install-pear-nozlib.phar
pear/phpize
pear/run-tests
pear/php-config
pear/scripts
sapi/apache/libphp5.module
sapi/apache2handler/libphp5.module
sapi/apache_hooks/libphp5.module
sapi/cgi/php-cgi
sapi/cli/php.1
sapi/fpm/php-fpm
sapi/fpm/php-fpm.1
sapi/fpm/init.d.php-fpm
sapi/fpm/php-fpm.conf
sapi/fpm/fpm/php-cgi
scripts/php-config
scripts/phpize
scripts/man1/*.1
win32/*.suo
win32/*.aps
win32/*.positions
win32/ext
win32/phpts.def
win32/wsyslog.h
win32/win32.dsp
win32/php.dsw
+1 -2
View File
@@ -12,8 +12,7 @@ php_lcov.info: lcov-test
@rm -rf lcov_data/
@$(mkinstalldirs) lcov_data/
@echo
-@files=`find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | uniq` ;\
for x in $$files; do \
-@find . -name \*.gcda -o -name \*.gcno -o -name \*.da -o -name \*.h | sed -e 's/^\.\///' | sed -e 's/\.gcda//g' -e 's/\.gcno//g' -e 's/\.da//g' | uniq | while read x; do \
echo -n . ;\
y=`echo $$x | sed -e 's!\.libs/!!'`; \
dir=lcov_data/`dirname $$x`; \
+20 -189
View File
@@ -1,179 +1,10 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
03 Mar 2012, PHP 5.3.12
- Fix PHP-CGI query string parameter vulnerability, CVE-2012-1823. (Rasmus)
26 Apr 2012, PHP 5.3.11
- Core:
. Fixed bug #61650 (ini parser crashes when using ${xxxx} ini variables
(without apache2)). (Laruence)
. Fixed bug #61273 (call_user_func_array with more than 16333 arguments
leaks / crashes). (Laruence)
. Fixed bug #61165 (Segfault - strip_tags()). (Laruence)
. Improved max_input_vars directive to check nested variables (Dmitry).
. Fixed bug #61095 (Incorect lexing of 0x00*+<NUM>). (Etienne)
. Fixed bug #61087 (Memory leak in parse_ini_file when specifying
invalid scanner mode). (Nikic, Laruence)
. Fixed bug #61072 (Memory leak when restoring an exception handler).
(Nikic, Laruence)
. Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX).
(Laruence)
. Fixed bug #61043 (Regression in magic_quotes_gpc fix for CVE-2012-0831).
(Ondřej Surý)
. Fixed bug #61000 (Exceeding max nesting level doesn't delete numerical
vars). (Laruence)
. Fixed bug #60895 (Possible invalid handler usage in windows random
functions). (Pierre)
. Fixed bug #60825 (Segfault when running symfony 2 tests).
(Dmitry, Laruence)
. Fixed bug #60801 (strpbrk() mishandles NUL byte). (Adam)
. Fixed bug #60569 (Nullbyte truncates Exception $message). (Ilia)
. Fixed bug #60227 (header() cannot detect the multi-line header with CR).
(rui, Gustavo)
. Fixed bug #60222 (time_nanosleep() does validate input params). (Ilia)
. Fixed bug #54374 (Insufficient validating of upload name leading to
corrupted $_FILES indices). (CVE-2012-1172). (Stas, lekensteyn at
gmail dot com, Pierre)
. Fixed bug #52719 (array_walk_recursive crashes if third param of the
function is by reference). (Nikita Popov)
. Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry)
- DOM
. Added debug info handler to DOM objects. (Gustavo, Joey Smith)
- FPM
. Fixed bug #61430 (Transposed memset() params in sapi/fpm/fpm/fpm_shm.c).
(michaelhood at gmail dot com, Ilia)
- Ibase
. Fixed bug #60947 (Segmentation fault while executing ibase_db_info).
(Ilia)
- Installation
. Fixed bug #61172 (Add Apache 2.4 support). (Chris Jones)
- Fileinfo
. Upgraded libmagic to 5.11 (Pierre, Anatoliy)
. Fixed bug #61565 where php_stream_open_wrapper_ex tries to open a
directory descriptor under windows. (Anatoliy)
. Fixed bug #61566 failure caused by the posix lseek and read versions
under windows in cdf_read(). (Anatoliy)
. Fixed bug #61173 (Unable to detect error from finfo constructor). (Gustavo)
- Firebird Database extension (ibase):
. Fixed bug #60802 (ibase_trans() gives segfault when passing params).
- Libxml:
. Fixed bug #61367 (open_basedir bypass using libxml RSHUTDOWN).
(Tim Starling)
- mysqli
. Fixed bug #61003 (mysql_stat() require a valid connection). (Johannes).
- PDO_mysql
. Fixed bug #61207 (PDO::nextRowset() after a multi-statement query doesn't
always work). (Johannes)
. Fixed bug #61194 (PDO should export compression flag with myslqnd).
(Johannes)
- PDO_odbc
. Fixed bug #61212 (PDO ODBC Segfaults on SQL_SUCESS_WITH_INFO). (Ilia)
- PDO_pgsql
. Fixed bug #61267 (pdo_pgsql's PDO::exec() returns the number of SELECTed
rows on postgresql >= 9). (ben dot pineau at gmail dot com)
- PDO_Sqlite extension:
. Add createCollation support. (Damien)
- pgsql:
. Fixed bug #60718 (Compile problem with libpq (PostgreSQL 7.3 or less).
(Yasuo Ohgaki)
- Phar:
. Fixed bug #61184 (Phar::webPhar() generates headers with trailing NUL
bytes). (Nikic)
- PHP-FPM SAPI:
. Fixed bug #60811 (php-fpm compilation problem). (rasmus)
- Readline:
. Fixed bug #61088 (Memory leak in readline_callback_handler_install).
(Nikic, Laruence)
. Add open_basedir checks to readline_write_history and readline_read_history.
(Rasmus, reported by Mateusz Goik)
- Reflection:
. Fixed bug #61388 (ReflectionObject:getProperties() issues invalid reads
when get_properties returns a hash table with (inaccessible) dynamic
numeric properties). (Gustavo)
. Fixed bug #60968 (Late static binding doesn't work with
ReflectionMethod::invokeArgs()). (Laruence)
- SOAP
. Fixed basic HTTP authentication for WSDL sub requests. (Dmitry)
. Fixed bug #60887 (SoapClient ignores user_agent option and sends no
User-Agent header). (carloschilazo at gmail dot com)
. Fixed bug #60842, #51775 (Chunked response parsing error when
chunksize length line is > 10 bytes). (Ilia)
. Fixed bug #49853 (Soap Client stream context header option ignored).
(Dmitry)
- SPL
. Fixed memory leak when calling SplFileInfo's constructor twice. (Felipe)
. Fixed bug #61418 (Segmentation fault when DirectoryIterator's or
FilesystemIterator's iterators are requested more than once without
having had its dtor callback called in between). (Gustavo)
. Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence)
. Fixed bug #61326 (ArrayObject comparison). (Gustavo)
- SQLite3 extension:
. Add createCollation() method. (Brad Dewar)
- Session:
. Fixed bug #60860 (session.save_handler=user without defined function core
dumps). (Felipe)
. Fixed bug #60634 (Segmentation fault when trying to die() in
SessionHandler::write()). (Ilia)
- Streams:
. Fixed bug #61371 (stream_context_create() causes memory leaks on use
streams_socket_create). (Gustavo)
. Fixed bug #61253 (Wrappers opened with errors concurrency problem on ZTS).
(Gustavo)
. Fixed bug #61115 (stream related segfault on fatal error in
php_stream_context_link). (Gustavo)
. Fixed bug #60817 (stream_get_line() reads from stream even when there is
already sufficient data buffered). stream_get_line() now behaves more like
fgets(), as is documented. (Gustavo)
. Further fix for bug #60455 (stream_get_line misbehaves if EOF is not
detected together with the last read). (Gustavo)
. Fixed bug #60106 (stream_socket_server silently truncates long unix
socket paths). (Ilia)
- Tidy:
. Fixed bug #54682 (tidy null pointer dereference). (Tony, David Soria Parra)
- XMLRPC:
. Fixed bug #61264 (xmlrpc_parse_method_descriptions leaks temporary
variable). (Nikita Popov)
. Fixed bug #61097 (Memory leak in xmlrpc functions copying zvals). (Nikic)
- Zlib:
. Fixed bug #61139 (gzopen leaks when specifying invalid mode). (Nikic)
02 Feb 2012, PHP 5.3.10
- Core:
. Fixed arbitrary remote code execution vulnerability reported by Stefan
Esser, CVE-2012-0830. (Stas, Dmitry)
10 Jan 2012, PHP 5.3.9
- Core:
. Added max_input_vars directive to prevent attacks based on hash collisions
(CVE-2011-4885) (Dmitry).
(Dmitry).
. Fixed bug #60205 (possible integer overflow in content_length). (Laruence)
. Fixed bug #60139 (Anonymous functions create cycles not detected by the
GC). (Dmitry)
@@ -252,7 +83,7 @@ PHP NEWS
- EXIF:
. Fixed bug #60150 (Integer overflow during the parsing of invalid exif
header). (CVE-2011-4566) (Stas, flolechaud at gmail dot com)
header). (Stas, flolechaud at gmail dot com)
- Fileinfo:
. Fixed bug #60094 (C++ comment fails in c89). (Laruence)
@@ -272,8 +103,6 @@ PHP NEWS
for small images). (Florian)
- Intl:
. Fixed bug #61487 (Incorrent bounds checking in grapheme_strpos).
(Stas)
. Fixed bug #60192 (SegFault when Collator not constructed
properly). (Florian)
. Fixed memory leak in several Intl locale functions. (Felipe)
@@ -344,35 +173,37 @@ PHP NEWS
- Phar:
. Fixed bug #60261 (NULL pointer dereference in phar). (Felipe)
. Fixed bug #60164 (Stubs of a specific length break phar_open_from_fp
scanning for __HALT_COMPILER). (Ralph Schindler)
. Fixed bug #53872 (internal corruption of phar). (Hannes)
. Fixed bug #52013 (Unable to decompress files in a compressed phar). (Hannes)
scanning for __HALT_COMPILER). (Ralph Schindler)
- PHP-FPM SAPI:
. Dropped restriction of not setting the same value multiple times, the last
one holds. (giovanni at giacobbi dot net, fat)
. Added .phar to default authorized extensions. (fat)
. Fixed bug #60659 (FPM does not clear auth_user on request accept).
(bonbons at linux-vserver dot org)
. Fixed bug #60629 (memory corruption when web server closed the fcgi fd).
(fat)
. Enhance error log when the primary script can't be open. FR #60199. (fat)
. Fixed bug #60179 (php_flag and php_value does not work properly). (fat)
. Fixed bug #55577 (status.html does not install). (fat)
. Fixed bug #55533 (The -d parameter doesn't work). (fat)
. Fixed bug #55526 (Heartbeat causes a lot of unnecessary events). (fat)
. Fixed bug #55533 (The -d parameter doesn't work). (fat)
. Implemented FR #52569 (Add the "ondemand" process-manager
to allow zero children). (fat)
. Fixed bug #55486 (status show BIG processes number). (fat)
. Enhanced security by limiting access to user defined extensions.
FR #55181. (fat)
. Added process.max to control the number of process FPM can fork. FR #55166.
(fat)
. Fixed bug #55577 (status.html does not install). (fat)
. Backported from 5.4 branch (Dropped restriction of not setting the same
value multiple times, the last one holds).
(giovanni at giacobbi dot net, fat)
. Backported FR #55166 from 5.4 branch (Added process.max to control
the number of process FPM can fork). (fat)
. Backported FR #55181 from 5.4 branch (Enhance security by limiting access
to user defined extensions). (fat)
. Backported FR #54098 from 5.4 branch (Lowered process manager
default value). (fat)
. Backported FR #52052 from 5.4 branch (Added partial syslog support). (fat)
. Implemented FR #54577 (Enhanced status page with full status and details
about each processes. Also provide a web page (status.html) for
real-time FPM status. (fat)
. Lowered default value for Process Manager. FR #54098. (fat)
. Implemented FR #52569 (Add the "ondemand" process-manager
to allow zero children). (fat)
. Added partial syslog support (on error_log only). FR #52052. (fat)
. Enhance error log when the primary script can't be open. FR #60199. (fat)
. Added .phar to default authorized extensions. (fat)
- Postgres:
. Fixed bug #60244 (pg_fetch_* functions do not validate that row param
@@ -914,7 +745,7 @@ PHP NEWS
- Tokenizer Extension
. Fixed bug #54089 (token_get_all() does not stop after __halt_compiler).
(Nikita Popov, Ilia)
(Ilia)
- XSL extension:
. Fixed memory leaked introduced by the NULL poisoning patch.
+4 -4
View File
@@ -104,7 +104,7 @@ Derick) run the following commands for you:
``sudo -u ezmlm ezmlm-sub ~ezmlm/primary-qa-tester/mod moderator-email-address``
3. Update ``qa.git/include/release-qa.php`` with the appropriate information.
3. Update ``web/qa/trunk/include/release-qa.php`` with the appropriate information.
See the documentation within release-qa.php for more information, but all releases
and RCs are configured here. Only $QA_RELEASES needs to be edited.
@@ -113,15 +113,15 @@ Derick) run the following commands for you:
Note: Remember to update the MD5 checksum information.
4. Update ``php.git/include/version.inc`` (x=major version number)
4. Update ``web/php/trunk/include/version.inc`` (x=major version number)
a. ``$PHP_x_RC`` = "5.3.0RC1"
b. ``$PHP_x_RC_DATE`` = "06 September 2007"
5. Commit and push those changes:
5. Commit those changes:
a. ``git commit -a && git push origin master``
a. ``svn commit web/qa/trunk web/php-bugs/trunk web/php/trunk``
6. For the first RC, write the doc team (phpdoc@lists.php.net) about updating the
INSTALL and win32/install.txt files which are generated from the PHP manual sources.
+1 -1
View File
@@ -88,7 +88,7 @@ PHP_MINFO_FUNCTION(my_input_filter)
{
php_info_print_table_start();
php_info_print_table_row( 2, "My Input Filter Support", "enabled" );
php_info_print_table_row( 2, "Revision", "$Id$");
php_info_print_table_row( 2, "Revision", "$Revision$");
php_info_print_table_end();
}
+3 -15
View File
@@ -773,9 +773,6 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
while (1) {
if (len <= start) {
if (link_is_dir) {
*link_is_dir = 1;
}
return start;
}
@@ -792,10 +789,6 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
continue;
} else if (i == len - 2 && path[i] == '.' && path[i+1] == '.') {
/* remove '..' and previous directory */
is_dir = 1;
if (link_is_dir) {
*link_is_dir = 1;
}
if (i - 1 <= start) {
return start ? start : len;
}
@@ -1221,14 +1214,9 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
return 1;
}
memcpy(resolved_path, state->cwd, state_cwd_length);
if (resolved_path[state_cwd_length-1] == DEFAULT_SLASH) {
memcpy(resolved_path + state_cwd_length, path, path_length + 1);
path_length += state_cwd_length;
} else {
resolved_path[state_cwd_length] = DEFAULT_SLASH;
memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1);
path_length += state_cwd_length + 1;
}
resolved_path[state_cwd_length] = DEFAULT_SLASH;
memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1);
path_length += state_cwd_length + 1;
}
} else {
#ifdef TSRM_WIN32
-8
View File
@@ -24,14 +24,6 @@ Zend MM disabled:
$ USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cli/php -r 'leak();'
Shared extensions:
------------------
Since PHP 5.3.11 it is possible to prevent shared extensions from unloading so
that valgrind can correctly track the memory leaks in shared extensions. For
this there is the ZEND_DONT_UNLOAD_MODULES environment variable. If set, then
DL_UNLOAD() is skipped during the shutdown of shared extensions.
Tweaking:
---------
+1 -1
View File
@@ -1,5 +1,5 @@
Title: Zend 2.0 Namespaces
Version: $Id$
Version: $Revision$
Status: declined
Maintainer: Stig S. Bakken <ssb@php.net>
Created: 2001-09-08
+1 -1
View File
@@ -1,5 +1,5 @@
Title: Loose type requirements for functions
Version: $Id$
Version: $Revision$
Status: draft
Maintainer: Brian Moon <brianm@dealnews.com>
Created: 2001-09-17
+1 -1
View File
@@ -1,7 +1,7 @@
--TEST--
Bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler)
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip SimpleXML extension required"; ?>
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php
$xml = "<root></root>";
+1 -1
View File
@@ -1,7 +1,7 @@
--TEST--
Bug #39602 (Invalid session.save_handler crashes PHP)
--SKIPIF--
<?php if (!extension_loaded("session")) die("skip session extension required"); ?>
<?php if (!extension_loaded("session")) die("skip"); ?>
--INI--
session.save_handler=qwerty
error_reporting=0
+1 -1
View File
@@ -1,7 +1,7 @@
--TEST--
Bug #42819 (namespaces in indexes of constant arrays)
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?>
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
namespace foo\foo;
+1 -1
View File
@@ -1,7 +1,7 @@
--TEST--
Bug #43918 (Segmentation fault in garbage collector)
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip SimpleXML extension required"; ?>
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php
$xmlstr = <<<XML
+1 -1
View File
@@ -1,7 +1,7 @@
--TEST--
Bug #50174 (Incorrectly matched docComment)
--SKIPIF--
<?php if (!extension_loaded('reflection') || !extension_loaded('spl')) print "skip SPL and reflection extensions required"; ?>
<?php if (!extension_loaded('reflection') || !extension_loaded('spl')) print "skip"; ?>
--FILE--
<?php
-2
View File
@@ -1,7 +1,5 @@
--TEST--
Bug #60139 (Anonymous functions create cycles not detected by the GC)
--INI--
zend.enable_gc=1
--FILE--
<?php
class Foo {
Binary file not shown.
-9
View File
@@ -1,9 +0,0 @@
--TEST--
test of larger than 8kb text file being parsed by require statement
--FILE--
<?php
file_put_contents('test.php',str_repeat('passed, ',1024));
require('test.php');
?>
--EXPECT--
passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed, passed,Line truncated
-19
View File
@@ -1,19 +0,0 @@
--TEST--
Bug #60825 (Segfault when running symfony 2 tests)
--DESCRIPTION--
run this with valgrind
--FILE--
<?php
class test {
public static $x;
public function __toString() {
self::$x = $this;
return __FILE__;
}
}
$a = new test;
require_once $a;
debug_zval_dump(test::$x);
?>
--EXPECTF--
string(%d) "%sbug60825.php" refcount(2)
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #61087 (Memory leak in parse_ini_file when specifying invalid scanner mode)
--FILE--
<?php
// the used file is actually irrelevant, so just use this file
// even though it's not an .ini
parse_ini_file(__FILE__, false, 100);
?>
--EXPECTF--
Warning: Invalid scanner mode in %s on line %d
-9
View File
@@ -1,9 +0,0 @@
--TEST--
Bug #61095 (Lexing 0x00*+<NUM> incorectly)
--FILE--
<?php
echo 0x00+2;
echo "\n";
?>
--EXPECT--
2
-28
View File
@@ -1,28 +0,0 @@
--TEST--
Bug #61165 (Segfault - strip_tags())
--FILE--
<?php
$handler = NULL;
class T {
public $_this;
public function __toString() {
global $handler;
$handler = $this;
$this->_this = $this; // <-- uncoment this
return 'A';
}
}
$t = new T;
for ($i = 0; $i < 3; $i++) {
strip_tags($t);
strip_tags(new T);
}
var_dump($handler);
--EXPECTF--
object(T)#%d (1) {
["_this"]=>
*RECURSION*
}
-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #61273 (call_user_func_array with more than 16333 arguments leaks / crashes)
--FILE--
<?php
/**
* for 5.3 #define ZEND_VM_STACK_PAGE_SIZE ((64 * 1024) - 64)
* for 5.4 #define ZEND_VM_STACK_PAGE_SIZE ((16 * 1024) - 16)
* we should trick EG(argument_stack) into growing
*/
$args = array_fill(0, 64 * 1024 - 64, 0);
call_user_func_array(function(&$a) {}, $args);
echo strval("okey");
--EXPECTF--
Warning: Parameter 1 to {closure}() expected to be a reference, value given in %sbug61273.php on line %d
okey
+1 -1
View File
@@ -3,7 +3,7 @@ GC 024: GC and objects with non-standard handlers
--INI--
zend.enable_gc=1
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?>
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
$a = new ArrayObject();
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
--TEST--
unset() CV 10 (unset() of global variable in ArrayObject::offsetUnset($GLOBALS))
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip SPL extension required"; ?>
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
$a = new ArrayObject($GLOBALS);
+5 -8
View File
@@ -33,6 +33,7 @@
#endif
/* these variables are true statics/globals, and have to be mutex'ed on every access */
static int module_count=0;
ZEND_API HashTable module_registry;
/* this function doesn't check for too many parameters */
@@ -253,14 +254,10 @@ ZEND_API int zend_get_object_classname(const zval *object, char **class_name, ze
static int parse_arg_object_to_string(zval **arg TSRMLS_DC) /* {{{ */
{
if (Z_OBJ_HANDLER_PP(arg, cast_object)) {
zval *obj;
MAKE_STD_ZVAL(obj);
if (Z_OBJ_HANDLER_P(*arg, cast_object)(*arg, obj, IS_STRING TSRMLS_CC) == SUCCESS) {
zval_ptr_dtor(arg);
*arg = obj;
SEPARATE_ZVAL_IF_NOT_REF(arg);
if (Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, IS_STRING TSRMLS_CC) == SUCCESS) {
return SUCCESS;
}
efree(obj);
}
/* Standard PHP objects */
if (Z_OBJ_HT_PP(arg) == &std_object_handlers || !Z_OBJ_HANDLER_PP(arg, cast_object)) {
@@ -2137,7 +2134,7 @@ void module_destructor(zend_module_entry *module) /* {{{ */
#if HAVE_LIBDL
#if !(defined(NETWARE) && defined(APACHE_1_BUILD))
if (module->handle && !getenv("ZEND_DONT_UNLOAD_MODULES")) {
if (module->handle) {
DL_UNLOAD(module->handle);
}
#endif
@@ -2183,7 +2180,7 @@ int module_registry_unload_temp(const zend_module_entry *module TSRMLS_DC) /* {{
/* return the next free module number */
int zend_next_free_module(void) /* {{{ */
{
return zend_hash_num_elements(&module_registry) + 1;
return ++module_count;
}
/* }}} */
+2 -1
View File
@@ -1516,7 +1516,8 @@ ZEND_FUNCTION(set_exception_handler)
RETURN_TRUE;
}
MAKE_COPY_ZVAL(&exception_handler, EG(user_exception_handler))
*EG(user_exception_handler) = *exception_handler;
zval_copy_ctor(EG(user_exception_handler));
if (!had_orig_exception_handler) {
RETURN_NULL();
+1 -1
View File
@@ -192,7 +192,7 @@ ZEND_METHOD(exception, __construct)
object = getThis();
if (message) {
zend_update_property_stringl(default_exception_ce, object, "message", sizeof("message")-1, message, message_len TSRMLS_CC);
zend_update_property_string(default_exception_ce, object, "message", sizeof("message")-1, message TSRMLS_CC);
}
if (code) {
+1 -1
View File
@@ -877,7 +877,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
if (fci->no_separation &&
!ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == EG(argument_stack)->top)) {
if(i) {
/* hack to clean up the stack */
zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC);
zend_vm_stack_clear_multiple(TSRMLS_C);
+116 -119
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 on Sat Feb 25 22:07:14 2012 */
/* Generated by re2c 0.13.5 on Fri Aug 26 18:01:17 2011 */
#line 1 "Zend/zend_ini_scanner.l"
/*
+----------------------------------------------------------------------+
@@ -230,12 +230,9 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML
char *buf;
size_t size;
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) {
return FAILURE;
}
if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) {
zend_file_handle_dtor(fh TSRMLS_CC);
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE ||
init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE
) {
return FAILURE;
}
@@ -333,7 +330,7 @@ restart:
}
}
#line 337 "Zend/zend_ini_scanner.c"
#line 334 "Zend/zend_ini_scanner.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -462,7 +459,7 @@ yy2:
yy3:
YYDEBUG(3, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 429 "Zend/zend_ini_scanner.l"
#line 426 "Zend/zend_ini_scanner.l"
{ /* Get option name */
/* Eat leading whitespace */
EAT_LEADING_WHITESPACE();
@@ -472,7 +469,7 @@ yy3:
RETURN_TOKEN(TC_LABEL, yytext, yyleng);
}
#line 476 "Zend/zend_ini_scanner.c"
#line 473 "Zend/zend_ini_scanner.c"
yy4:
YYDEBUG(4, *YYCURSOR);
yyaccept = 0;
@@ -481,24 +478,24 @@ yy4:
yy5:
YYDEBUG(5, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 547 "Zend/zend_ini_scanner.l"
#line 544 "Zend/zend_ini_scanner.l"
{
/* eat whitespace */
goto restart;
}
#line 490 "Zend/zend_ini_scanner.c"
#line 487 "Zend/zend_ini_scanner.c"
yy6:
YYDEBUG(6, *YYCURSOR);
++YYCURSOR;
yy7:
YYDEBUG(7, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 552 "Zend/zend_ini_scanner.l"
#line 549 "Zend/zend_ini_scanner.l"
{
SCNG(lineno)++;
return END_OF_LINE;
}
#line 502 "Zend/zend_ini_scanner.c"
#line 499 "Zend/zend_ini_scanner.c"
yy8:
YYDEBUG(8, *YYCURSOR);
yych = *++YYCURSOR;
@@ -533,11 +530,11 @@ yy10:
++YYCURSOR;
YYDEBUG(11, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 475 "Zend/zend_ini_scanner.l"
#line 472 "Zend/zend_ini_scanner.l"
{ /* Disallow these chars outside option values */
return yytext[0];
}
#line 541 "Zend/zend_ini_scanner.c"
#line 538 "Zend/zend_ini_scanner.c"
yy12:
YYDEBUG(12, *YYCURSOR);
yyaccept = 1;
@@ -554,11 +551,11 @@ yy14:
goto yy54;
YYDEBUG(15, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 575 "Zend/zend_ini_scanner.l"
#line 572 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 562 "Zend/zend_ini_scanner.c"
#line 559 "Zend/zend_ini_scanner.c"
yy16:
YYDEBUG(16, *YYCURSOR);
++YYCURSOR;
@@ -567,7 +564,7 @@ yy16:
yy17:
YYDEBUG(17, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 439 "Zend/zend_ini_scanner.l"
#line 436 "Zend/zend_ini_scanner.l"
{ /* Start option value */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
yy_push_state(ST_RAW TSRMLS_CC);
@@ -576,7 +573,7 @@ yy17:
}
return '=';
}
#line 580 "Zend/zend_ini_scanner.c"
#line 577 "Zend/zend_ini_scanner.c"
yy18:
YYDEBUG(18, *YYCURSOR);
yych = *++YYCURSOR;
@@ -632,7 +629,7 @@ yy23:
++YYCURSOR;
YYDEBUG(24, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 358 "Zend/zend_ini_scanner.l"
#line 355 "Zend/zend_ini_scanner.l"
{ /* Section start */
/* Enter section data lookup state */
if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) {
@@ -642,7 +639,7 @@ yy23:
}
return TC_SECTION;
}
#line 646 "Zend/zend_ini_scanner.c"
#line 643 "Zend/zend_ini_scanner.c"
yy25:
YYDEBUG(25, *YYCURSOR);
++YYCURSOR;
@@ -672,7 +669,7 @@ yy28:
}
YYDEBUG(30, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 383 "Zend/zend_ini_scanner.l"
#line 380 "Zend/zend_ini_scanner.l"
{ /* Start of option with offset */
/* Eat leading whitespace */
EAT_LEADING_WHITESPACE();
@@ -685,7 +682,7 @@ yy28:
RETURN_TOKEN(TC_OFFSET, yytext, yyleng);
}
#line 689 "Zend/zend_ini_scanner.c"
#line 686 "Zend/zend_ini_scanner.c"
yy31:
YYDEBUG(31, *YYCURSOR);
++YYCURSOR;
@@ -733,11 +730,11 @@ yy31:
yy33:
YYDEBUG(33, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 421 "Zend/zend_ini_scanner.l"
#line 418 "Zend/zend_ini_scanner.l"
{ /* TRUE value (when used outside option value/offset this causes parse error!) */
RETURN_TOKEN(BOOL_TRUE, "1", 1);
}
#line 741 "Zend/zend_ini_scanner.c"
#line 738 "Zend/zend_ini_scanner.c"
yy34:
YYDEBUG(34, *YYCURSOR);
++YYCURSOR;
@@ -807,11 +804,11 @@ yy39:
yy41:
YYDEBUG(41, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 425 "Zend/zend_ini_scanner.l"
#line 422 "Zend/zend_ini_scanner.l"
{ /* FALSE value (when used outside option value/offset this causes parse error!)*/
RETURN_TOKEN(BOOL_FALSE, "", 0);
}
#line 815 "Zend/zend_ini_scanner.c"
#line 812 "Zend/zend_ini_scanner.c"
yy42:
YYDEBUG(42, *YYCURSOR);
++YYCURSOR;
@@ -926,13 +923,13 @@ yy55:
yy56:
YYDEBUG(56, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 557 "Zend/zend_ini_scanner.l"
#line 554 "Zend/zend_ini_scanner.l"
{ /* Comment */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 936 "Zend/zend_ini_scanner.c"
#line 933 "Zend/zend_ini_scanner.c"
yy57:
YYDEBUG(57, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1012,14 +1009,14 @@ yy64:
yy65:
YYDEBUG(65, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 563 "Zend/zend_ini_scanner.l"
#line 560 "Zend/zend_ini_scanner.l"
{ /* #Comment */
zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno));
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 1023 "Zend/zend_ini_scanner.c"
#line 1020 "Zend/zend_ini_scanner.c"
yy66:
YYDEBUG(66, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1159,7 +1156,7 @@ yyc_ST_DOUBLE_QUOTES:
yy76:
YYDEBUG(76, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 507 "Zend/zend_ini_scanner.l"
#line 504 "Zend/zend_ini_scanner.l"
{ /* Escape double quoted string contents */
if (YYCURSOR > YYLIMIT) {
return 0;
@@ -1195,7 +1192,7 @@ yy76:
zend_ini_escape_string(ini_lval, yytext, yyleng, '"' TSRMLS_CC);
return TC_QUOTED_STRING;
}
#line 1199 "Zend/zend_ini_scanner.c"
#line 1196 "Zend/zend_ini_scanner.c"
yy77:
YYDEBUG(77, *YYCURSOR);
++YYCURSOR;
@@ -1204,12 +1201,12 @@ yy77:
yy78:
YYDEBUG(78, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 502 "Zend/zend_ini_scanner.l"
#line 499 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string ends */
yy_pop_state(TSRMLS_C);
return '"';
}
#line 1213 "Zend/zend_ini_scanner.c"
#line 1210 "Zend/zend_ini_scanner.c"
yy79:
YYDEBUG(79, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1218,12 +1215,12 @@ yy79:
++YYCURSOR;
YYDEBUG(81, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 401 "Zend/zend_ini_scanner.l"
#line 398 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC);
return TC_DOLLAR_CURLY;
}
#line 1227 "Zend/zend_ini_scanner.c"
#line 1224 "Zend/zend_ini_scanner.c"
yy82:
YYDEBUG(82, *YYCURSOR);
++YYCURSOR;
@@ -1323,11 +1320,11 @@ yy86:
yy87:
YYDEBUG(87, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 493 "Zend/zend_ini_scanner.l"
#line 490 "Zend/zend_ini_scanner.l"
{ /* Get rest as section/offset value */
RETURN_TOKEN(TC_STRING, yytext, yyleng);
}
#line 1331 "Zend/zend_ini_scanner.c"
#line 1328 "Zend/zend_ini_scanner.c"
yy88:
YYDEBUG(88, *YYCURSOR);
yyaccept = 0;
@@ -1344,23 +1341,23 @@ yy89:
yy90:
YYDEBUG(90, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 575 "Zend/zend_ini_scanner.l"
#line 572 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 1352 "Zend/zend_ini_scanner.c"
#line 1349 "Zend/zend_ini_scanner.c"
yy91:
YYDEBUG(91, *YYCURSOR);
++YYCURSOR;
yy92:
YYDEBUG(92, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 497 "Zend/zend_ini_scanner.l"
#line 494 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
return '"';
}
#line 1364 "Zend/zend_ini_scanner.c"
#line 1361 "Zend/zend_ini_scanner.c"
yy93:
YYDEBUG(93, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1422,11 +1419,11 @@ yy97:
yy98:
YYDEBUG(98, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 471 "Zend/zend_ini_scanner.l"
#line 468 "Zend/zend_ini_scanner.l"
{ /* Get number option value as string */
RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
}
#line 1430 "Zend/zend_ini_scanner.c"
#line 1427 "Zend/zend_ini_scanner.c"
yy99:
YYDEBUG(99, *YYCURSOR);
yyaccept = 3;
@@ -1452,11 +1449,11 @@ yy99:
yy100:
YYDEBUG(100, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 467 "Zend/zend_ini_scanner.l"
#line 464 "Zend/zend_ini_scanner.l"
{ /* Get constant option value */
RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
}
#line 1460 "Zend/zend_ini_scanner.c"
#line 1457 "Zend/zend_ini_scanner.c"
yy101:
YYDEBUG(101, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1467,12 +1464,12 @@ yy102:
yy103:
YYDEBUG(103, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 396 "Zend/zend_ini_scanner.l"
#line 393 "Zend/zend_ini_scanner.l"
{ /* End of section or an option offset */
BEGIN(INITIAL);
return ']';
}
#line 1476 "Zend/zend_ini_scanner.c"
#line 1473 "Zend/zend_ini_scanner.c"
yy104:
YYDEBUG(104, *YYCURSOR);
yyaccept = 0;
@@ -1762,7 +1759,7 @@ yy125:
++YYCURSOR;
YYDEBUG(128, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 368 "Zend/zend_ini_scanner.l"
#line 365 "Zend/zend_ini_scanner.l"
{ /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -1771,18 +1768,18 @@ yy125:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 1775 "Zend/zend_ini_scanner.c"
#line 1772 "Zend/zend_ini_scanner.c"
yy129:
YYDEBUG(129, *YYCURSOR);
++YYCURSOR;
YYDEBUG(130, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 401 "Zend/zend_ini_scanner.l"
#line 398 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC);
return TC_DOLLAR_CURLY;
}
#line 1786 "Zend/zend_ini_scanner.c"
#line 1783 "Zend/zend_ini_scanner.c"
yy131:
YYDEBUG(131, *YYCURSOR);
yyaccept = 0;
@@ -1887,12 +1884,12 @@ yyc_ST_RAW:
++YYCURSOR;
YYDEBUG(138, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 570 "Zend/zend_ini_scanner.l"
#line 567 "Zend/zend_ini_scanner.l"
{ /* End of option value (if EOF is reached before EOL */
BEGIN(INITIAL);
return END_OF_LINE;
}
#line 1896 "Zend/zend_ini_scanner.c"
#line 1893 "Zend/zend_ini_scanner.c"
yy139:
YYDEBUG(139, *YYCURSOR);
++YYCURSOR;
@@ -1901,7 +1898,7 @@ yy139:
yy140:
YYDEBUG(140, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 448 "Zend/zend_ini_scanner.l"
#line 445 "Zend/zend_ini_scanner.l"
{ /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
/* Eat leading and trailing double quotes */
if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
@@ -1910,7 +1907,7 @@ yy140:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 1914 "Zend/zend_ini_scanner.c"
#line 1911 "Zend/zend_ini_scanner.c"
yy141:
YYDEBUG(141, *YYCURSOR);
yyaccept = 0;
@@ -1932,13 +1929,13 @@ yy142:
yy143:
YYDEBUG(143, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 461 "Zend/zend_ini_scanner.l"
#line 458 "Zend/zend_ini_scanner.l"
{ /* End of option value */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 1942 "Zend/zend_ini_scanner.c"
#line 1939 "Zend/zend_ini_scanner.c"
yy144:
YYDEBUG(144, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1966,13 +1963,13 @@ yy148:
yy149:
YYDEBUG(149, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 557 "Zend/zend_ini_scanner.l"
#line 554 "Zend/zend_ini_scanner.l"
{ /* Comment */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 1976 "Zend/zend_ini_scanner.c"
#line 1973 "Zend/zend_ini_scanner.c"
yy150:
YYDEBUG(150, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2071,21 +2068,21 @@ yyc_ST_SECTION_RAW:
yy160:
YYDEBUG(160, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 457 "Zend/zend_ini_scanner.l"
#line 454 "Zend/zend_ini_scanner.l"
{ /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 2079 "Zend/zend_ini_scanner.c"
#line 2076 "Zend/zend_ini_scanner.c"
yy161:
YYDEBUG(161, *YYCURSOR);
++YYCURSOR;
YYDEBUG(162, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 575 "Zend/zend_ini_scanner.l"
#line 572 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 2089 "Zend/zend_ini_scanner.c"
#line 2086 "Zend/zend_ini_scanner.c"
yy163:
YYDEBUG(163, *YYCURSOR);
++YYCURSOR;
@@ -2094,13 +2091,13 @@ yy163:
yy164:
YYDEBUG(164, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 377 "Zend/zend_ini_scanner.l"
#line 374 "Zend/zend_ini_scanner.l"
{ /* End of section */
BEGIN(INITIAL);
SCNG(lineno)++;
return ']';
}
#line 2104 "Zend/zend_ini_scanner.c"
#line 2101 "Zend/zend_ini_scanner.c"
yy165:
YYDEBUG(165, *YYCURSOR);
++YYCURSOR;
@@ -2222,11 +2219,11 @@ yy173:
yy174:
YYDEBUG(174, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 493 "Zend/zend_ini_scanner.l"
#line 490 "Zend/zend_ini_scanner.l"
{ /* Get rest as section/offset value */
RETURN_TOKEN(TC_STRING, yytext, yyleng);
}
#line 2230 "Zend/zend_ini_scanner.c"
#line 2227 "Zend/zend_ini_scanner.c"
yy175:
YYDEBUG(175, *YYCURSOR);
yyaccept = 0;
@@ -2245,23 +2242,23 @@ yy176:
yy177:
YYDEBUG(177, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 575 "Zend/zend_ini_scanner.l"
#line 572 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 2253 "Zend/zend_ini_scanner.c"
#line 2250 "Zend/zend_ini_scanner.c"
yy178:
YYDEBUG(178, *YYCURSOR);
++YYCURSOR;
yy179:
YYDEBUG(179, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 497 "Zend/zend_ini_scanner.l"
#line 494 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
return '"';
}
#line 2265 "Zend/zend_ini_scanner.c"
#line 2262 "Zend/zend_ini_scanner.c"
yy180:
YYDEBUG(180, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2323,11 +2320,11 @@ yy184:
yy185:
YYDEBUG(185, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 471 "Zend/zend_ini_scanner.l"
#line 468 "Zend/zend_ini_scanner.l"
{ /* Get number option value as string */
RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
}
#line 2331 "Zend/zend_ini_scanner.c"
#line 2328 "Zend/zend_ini_scanner.c"
yy186:
YYDEBUG(186, *YYCURSOR);
yyaccept = 3;
@@ -2353,11 +2350,11 @@ yy186:
yy187:
YYDEBUG(187, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 467 "Zend/zend_ini_scanner.l"
#line 464 "Zend/zend_ini_scanner.l"
{ /* Get constant option value */
RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
}
#line 2361 "Zend/zend_ini_scanner.c"
#line 2358 "Zend/zend_ini_scanner.c"
yy188:
YYDEBUG(188, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2370,13 +2367,13 @@ yy189:
yy190:
YYDEBUG(190, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 377 "Zend/zend_ini_scanner.l"
#line 374 "Zend/zend_ini_scanner.l"
{ /* End of section */
BEGIN(INITIAL);
SCNG(lineno)++;
return ']';
}
#line 2380 "Zend/zend_ini_scanner.c"
#line 2377 "Zend/zend_ini_scanner.c"
yy191:
YYDEBUG(191, *YYCURSOR);
++YYCURSOR;
@@ -2688,7 +2685,7 @@ yy216:
++YYCURSOR;
YYDEBUG(219, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 368 "Zend/zend_ini_scanner.l"
#line 365 "Zend/zend_ini_scanner.l"
{ /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -2697,18 +2694,18 @@ yy216:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 2701 "Zend/zend_ini_scanner.c"
#line 2698 "Zend/zend_ini_scanner.c"
yy220:
YYDEBUG(220, *YYCURSOR);
++YYCURSOR;
YYDEBUG(221, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 401 "Zend/zend_ini_scanner.l"
#line 398 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC);
return TC_DOLLAR_CURLY;
}
#line 2712 "Zend/zend_ini_scanner.c"
#line 2709 "Zend/zend_ini_scanner.c"
yy222:
YYDEBUG(222, *YYCURSOR);
yyaccept = 0;
@@ -2888,12 +2885,12 @@ yy227:
yy228:
YYDEBUG(228, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 570 "Zend/zend_ini_scanner.l"
#line 567 "Zend/zend_ini_scanner.l"
{ /* End of option value (if EOF is reached before EOL */
BEGIN(INITIAL);
return END_OF_LINE;
}
#line 2897 "Zend/zend_ini_scanner.c"
#line 2894 "Zend/zend_ini_scanner.c"
yy229:
YYDEBUG(229, *YYCURSOR);
yyaccept = 0;
@@ -2902,11 +2899,11 @@ yy229:
yy230:
YYDEBUG(230, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 489 "Zend/zend_ini_scanner.l"
#line 486 "Zend/zend_ini_scanner.l"
{ /* Get everything else as option/offset value */
RETURN_TOKEN(TC_STRING, yytext, yyleng);
}
#line 2910 "Zend/zend_ini_scanner.c"
#line 2907 "Zend/zend_ini_scanner.c"
yy231:
YYDEBUG(231, *YYCURSOR);
yyaccept = 1;
@@ -2915,24 +2912,24 @@ yy231:
yy232:
YYDEBUG(232, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 543 "Zend/zend_ini_scanner.l"
#line 540 "Zend/zend_ini_scanner.l"
{
RETURN_TOKEN(TC_WHITESPACE, yytext, yyleng);
}
#line 2923 "Zend/zend_ini_scanner.c"
#line 2920 "Zend/zend_ini_scanner.c"
yy233:
YYDEBUG(233, *YYCURSOR);
++YYCURSOR;
yy234:
YYDEBUG(234, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 461 "Zend/zend_ini_scanner.l"
#line 458 "Zend/zend_ini_scanner.l"
{ /* End of option value */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 2936 "Zend/zend_ini_scanner.c"
#line 2933 "Zend/zend_ini_scanner.c"
yy235:
YYDEBUG(235, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2946,23 +2943,23 @@ yy236:
yy237:
YYDEBUG(237, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 479 "Zend/zend_ini_scanner.l"
#line 476 "Zend/zend_ini_scanner.l"
{ /* Boolean operators */
return yytext[0];
}
#line 2954 "Zend/zend_ini_scanner.c"
#line 2951 "Zend/zend_ini_scanner.c"
yy238:
YYDEBUG(238, *YYCURSOR);
++YYCURSOR;
yy239:
YYDEBUG(239, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 497 "Zend/zend_ini_scanner.l"
#line 494 "Zend/zend_ini_scanner.l"
{ /* Double quoted '"' string start */
yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
return '"';
}
#line 2966 "Zend/zend_ini_scanner.c"
#line 2963 "Zend/zend_ini_scanner.c"
yy240:
YYDEBUG(240, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3038,11 +3035,11 @@ yy244:
yy245:
YYDEBUG(245, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 471 "Zend/zend_ini_scanner.l"
#line 468 "Zend/zend_ini_scanner.l"
{ /* Get number option value as string */
RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
}
#line 3046 "Zend/zend_ini_scanner.c"
#line 3043 "Zend/zend_ini_scanner.c"
yy246:
YYDEBUG(246, *YYCURSOR);
yyaccept = 2;
@@ -3053,13 +3050,13 @@ yy247:
++YYCURSOR;
YYDEBUG(248, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 483 "Zend/zend_ini_scanner.l"
#line 480 "Zend/zend_ini_scanner.l"
{ /* Make = used in option value to trigger error */
yyless(0);
BEGIN(INITIAL);
return END_OF_LINE;
}
#line 3063 "Zend/zend_ini_scanner.c"
#line 3060 "Zend/zend_ini_scanner.c"
yy249:
YYDEBUG(249, *YYCURSOR);
yyaccept = 4;
@@ -3095,11 +3092,11 @@ yy249:
yy250:
YYDEBUG(250, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 467 "Zend/zend_ini_scanner.l"
#line 464 "Zend/zend_ini_scanner.l"
{ /* Get constant option value */
RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
}
#line 3103 "Zend/zend_ini_scanner.c"
#line 3100 "Zend/zend_ini_scanner.c"
yy251:
YYDEBUG(251, *YYCURSOR);
yyaccept = 4;
@@ -3591,11 +3588,11 @@ yy266:
yy267:
YYDEBUG(267, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 421 "Zend/zend_ini_scanner.l"
#line 418 "Zend/zend_ini_scanner.l"
{ /* TRUE value (when used outside option value/offset this causes parse error!) */
RETURN_TOKEN(BOOL_TRUE, "1", 1);
}
#line 3599 "Zend/zend_ini_scanner.c"
#line 3596 "Zend/zend_ini_scanner.c"
yy268:
YYDEBUG(268, *YYCURSOR);
++YYCURSOR;
@@ -3795,11 +3792,11 @@ yy273:
yy274:
YYDEBUG(274, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 425 "Zend/zend_ini_scanner.l"
#line 422 "Zend/zend_ini_scanner.l"
{ /* FALSE value (when used outside option value/offset this causes parse error!)*/
RETURN_TOKEN(BOOL_FALSE, "", 0);
}
#line 3803 "Zend/zend_ini_scanner.c"
#line 3800 "Zend/zend_ini_scanner.c"
yy275:
YYDEBUG(275, *YYCURSOR);
++YYCURSOR;
@@ -4175,13 +4172,13 @@ yy286:
yy287:
YYDEBUG(287, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 557 "Zend/zend_ini_scanner.l"
#line 554 "Zend/zend_ini_scanner.l"
{ /* Comment */
BEGIN(INITIAL);
SCNG(lineno)++;
return END_OF_LINE;
}
#line 4185 "Zend/zend_ini_scanner.c"
#line 4182 "Zend/zend_ini_scanner.c"
yy288:
YYDEBUG(288, *YYCURSOR);
yych = *++YYCURSOR;
@@ -4393,7 +4390,7 @@ yy297:
++YYCURSOR;
YYDEBUG(300, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 368 "Zend/zend_ini_scanner.l"
#line 365 "Zend/zend_ini_scanner.l"
{ /* Raw string */
/* Eat leading and trailing single quotes */
if (yytext[0] == '\'' && yytext[yyleng - 1] == '\'') {
@@ -4402,18 +4399,18 @@ yy297:
}
RETURN_TOKEN(TC_RAW, yytext, yyleng);
}
#line 4406 "Zend/zend_ini_scanner.c"
#line 4403 "Zend/zend_ini_scanner.c"
yy301:
YYDEBUG(301, *YYCURSOR);
++YYCURSOR;
YYDEBUG(302, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 401 "Zend/zend_ini_scanner.l"
#line 398 "Zend/zend_ini_scanner.l"
{ /* Variable start */
yy_push_state(ST_VARNAME TSRMLS_CC);
return TC_DOLLAR_CURLY;
}
#line 4417 "Zend/zend_ini_scanner.c"
#line 4414 "Zend/zend_ini_scanner.c"
yy303:
YYDEBUG(303, *YYCURSOR);
++YYCURSOR;
@@ -4542,7 +4539,7 @@ yyc_ST_VARNAME:
yy313:
YYDEBUG(313, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 406 "Zend/zend_ini_scanner.l"
#line 403 "Zend/zend_ini_scanner.l"
{ /* Variable name */
/* Eat leading whitespace */
EAT_LEADING_WHITESPACE();
@@ -4552,28 +4549,28 @@ yy313:
RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
}
#line 4556 "Zend/zend_ini_scanner.c"
#line 4553 "Zend/zend_ini_scanner.c"
yy314:
YYDEBUG(314, *YYCURSOR);
++YYCURSOR;
YYDEBUG(315, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 575 "Zend/zend_ini_scanner.l"
#line 572 "Zend/zend_ini_scanner.l"
{
return 0;
}
#line 4566 "Zend/zend_ini_scanner.c"
#line 4563 "Zend/zend_ini_scanner.c"
yy316:
YYDEBUG(316, *YYCURSOR);
++YYCURSOR;
YYDEBUG(317, *YYCURSOR);
yyleng = YYCURSOR - SCNG(yy_text);
#line 416 "Zend/zend_ini_scanner.l"
#line 413 "Zend/zend_ini_scanner.l"
{ /* Variable end */
yy_pop_state(TSRMLS_C);
return '}';
}
#line 4577 "Zend/zend_ini_scanner.c"
#line 4574 "Zend/zend_ini_scanner.c"
yy318:
YYDEBUG(318, *YYCURSOR);
++YYCURSOR;
@@ -4587,6 +4584,6 @@ yy319:
goto yy313;
}
}
#line 579 "Zend/zend_ini_scanner.l"
#line 576 "Zend/zend_ini_scanner.l"
}
+3 -6
View File
@@ -228,12 +228,9 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML
char *buf;
size_t size;
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) {
return FAILURE;
}
if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) {
zend_file_handle_dtor(fh TSRMLS_CC);
if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE ||
init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE
) {
return FAILURE;
}
+1 -1
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 on Sat Feb 25 22:07:14 2012 */
/* Generated by re2c 0.13.5 on Fri Aug 26 18:01:17 2011 */
#line 3 "Zend/zend_ini_scanner_defs.h"
enum YYCONDTYPE {
File diff suppressed because it is too large. Load diff
+1 -5
View File
@@ -1361,11 +1361,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
}
if (len < SIZEOF_LONG * 2 || (len == SIZEOF_LONG * 2 && *hex <= '7')) {
if (len == 0) {
zendlval->value.lval = 0;
} else {
zendlval->value.lval = strtol(hex, NULL, 16);
}
zendlval->value.lval = strtol(hex, NULL, 16);
zendlval->type = IS_LONG;
return T_LNUMBER;
} else {
+1 -1
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 on Wed Feb 15 17:38:31 2012 */
/* Generated by re2c 0.13.5 on Mon Jan 3 05:56:03 2011 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {
+7 -8
View File
@@ -3224,15 +3224,14 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
int return_value_used;
zend_free_op free_op1;
zval *inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R);
zval *tmp_inc_filename = NULL;
zval tmp_inc_filename;
zend_bool failure_retval=0;
if (inc_filename->type!=IS_STRING) {
MAKE_STD_ZVAL(tmp_inc_filename);
*tmp_inc_filename = *inc_filename;
zval_copy_ctor(tmp_inc_filename);
convert_to_string(tmp_inc_filename);
inc_filename = tmp_inc_filename;
tmp_inc_filename = *inc_filename;
zval_copy_ctor(&tmp_inc_filename);
convert_to_string(&tmp_inc_filename);
inc_filename = &tmp_inc_filename;
}
return_value_used = RETURN_VALUE_USED(opline);
@@ -3298,8 +3297,8 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
EMPTY_SWITCH_DEFAULT_CASE()
}
}
if (tmp_inc_filename) {
zval_ptr_dtor(&tmp_inc_filename);
if (inc_filename==&tmp_inc_filename) {
zval_dtor(&tmp_inc_filename);
}
FREE_OP1();
EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr;
+28 -32
View File
@@ -1902,15 +1902,14 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA
int return_value_used;
zval *inc_filename = &opline->op1.u.constant;
zval *tmp_inc_filename = NULL;
zval tmp_inc_filename;
zend_bool failure_retval=0;
if (inc_filename->type!=IS_STRING) {
MAKE_STD_ZVAL(tmp_inc_filename);
*tmp_inc_filename = *inc_filename;
zval_copy_ctor(tmp_inc_filename);
convert_to_string(tmp_inc_filename);
inc_filename = tmp_inc_filename;
tmp_inc_filename = *inc_filename;
zval_copy_ctor(&tmp_inc_filename);
convert_to_string(&tmp_inc_filename);
inc_filename = &tmp_inc_filename;
}
return_value_used = RETURN_VALUE_USED(opline);
@@ -1976,8 +1975,8 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA
EMPTY_SWITCH_DEFAULT_CASE()
}
}
if (tmp_inc_filename) {
zval_ptr_dtor(&tmp_inc_filename);
if (inc_filename==&tmp_inc_filename) {
zval_dtor(&tmp_inc_filename);
}
EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr;
@@ -5191,15 +5190,14 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND
int return_value_used;
zend_free_op free_op1;
zval *inc_filename = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
zval *tmp_inc_filename = NULL;
zval tmp_inc_filename;
zend_bool failure_retval=0;
if (inc_filename->type!=IS_STRING) {
MAKE_STD_ZVAL(tmp_inc_filename);
*tmp_inc_filename = *inc_filename;
zval_copy_ctor(tmp_inc_filename);
convert_to_string(tmp_inc_filename);
inc_filename = tmp_inc_filename;
tmp_inc_filename = *inc_filename;
zval_copy_ctor(&tmp_inc_filename);
convert_to_string(&tmp_inc_filename);
inc_filename = &tmp_inc_filename;
}
return_value_used = RETURN_VALUE_USED(opline);
@@ -5265,8 +5263,8 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND
EMPTY_SWITCH_DEFAULT_CASE()
}
}
if (tmp_inc_filename) {
zval_ptr_dtor(&tmp_inc_filename);
if (inc_filename==&tmp_inc_filename) {
zval_dtor(&tmp_inc_filename);
}
zval_dtor(free_op1.var);
EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr;
@@ -8575,15 +8573,14 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
int return_value_used;
zend_free_op free_op1;
zval *inc_filename = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
zval *tmp_inc_filename = NULL;
zval tmp_inc_filename;
zend_bool failure_retval=0;
if (inc_filename->type!=IS_STRING) {
MAKE_STD_ZVAL(tmp_inc_filename);
*tmp_inc_filename = *inc_filename;
zval_copy_ctor(tmp_inc_filename);
convert_to_string(tmp_inc_filename);
inc_filename = tmp_inc_filename;
tmp_inc_filename = *inc_filename;
zval_copy_ctor(&tmp_inc_filename);
convert_to_string(&tmp_inc_filename);
inc_filename = &tmp_inc_filename;
}
return_value_used = RETURN_VALUE_USED(opline);
@@ -8649,8 +8646,8 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
EMPTY_SWITCH_DEFAULT_CASE()
}
}
if (tmp_inc_filename) {
zval_ptr_dtor(&tmp_inc_filename);
if (inc_filename==&tmp_inc_filename) {
zval_dtor(&tmp_inc_filename);
}
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr;
@@ -22468,15 +22465,14 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
int return_value_used;
zval *inc_filename = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
zval *tmp_inc_filename = NULL;
zval tmp_inc_filename;
zend_bool failure_retval=0;
if (inc_filename->type!=IS_STRING) {
MAKE_STD_ZVAL(tmp_inc_filename);
*tmp_inc_filename = *inc_filename;
zval_copy_ctor(tmp_inc_filename);
convert_to_string(tmp_inc_filename);
inc_filename = tmp_inc_filename;
tmp_inc_filename = *inc_filename;
zval_copy_ctor(&tmp_inc_filename);
convert_to_string(&tmp_inc_filename);
inc_filename = &tmp_inc_filename;
}
return_value_used = RETURN_VALUE_USED(opline);
@@ -22542,8 +22538,8 @@ static int ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
EMPTY_SWITCH_DEFAULT_CASE()
}
}
if (tmp_inc_filename) {
zval_ptr_dtor(&tmp_inc_filename);
if (inc_filename==&tmp_inc_filename) {
zval_dtor(&tmp_inc_filename);
}
EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr;
+2 -17
View File
@@ -41,7 +41,7 @@ AC_CONFIG_HEADER(main/php_config.h)
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=3
PHP_RELEASE_VERSION=12
PHP_RELEASE_VERSION=9
PHP_EXTRA_VERSION=""
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
@@ -155,7 +155,7 @@ dnl Check if bison generated files exist when bison does not..
case $php_cv_bison_version in
""|invalid[)]
if ! test -f "$abs_srcdir/Zend/zend_language_parser.h" || ! test -f "$abs_srcdir/Zend/zend_language_parser.c" ; then
AC_MSG_ERROR([bison is required to build PHP/Zend when building a GIT checkout!])
AC_MSG_ERROR([bison is required to build PHP/Zend when building a SVN checkout!])
fi
;;
esac
@@ -1550,21 +1550,6 @@ cat <<X
X
fi
if test "$PHP_SAPI" = "apache2handler" || test "$PHP_SAPI" = "apache2filter"; then
if test "$APACHE_VERSION" -ge 2004001; then
if test -z "$APACHE_THREADED_MPM"; then
cat <<X
+--------------------------------------------------------------------+
| *** WARNING *** |
| |
| You have built PHP for Apache's current non-threaded MPM. |
| If you change Apache to use a threaded MPM you must reconfigure |
| PHP with --enable-maintainer-zts |
X
fi
fi
fi
# Warn about linking Apache with libpthread if oci8 extension is enabled on linux.
if test "$PHP_OCI8" != "no"; then
if test "$PHP_SAPI" = "apache"; then
+1 -1
View File
@@ -26,5 +26,5 @@ curl_close($ch);
?>
--EXPECTF--
%unicode|string%(%d) "%r(Couldn't resolve proxy|Could not resolve proxy:|Could not resolve host:)%r %s"
%unicode|string%(%d) "%r(Couldn't resolve proxy|Could not resolve proxy:)%r %s"
int(5)
+725 -727
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -75,7 +75,7 @@ result = Monday 1983-04-18 01:00:00 CEST
wanted = Monday 00:00:00
Asia/Yerevan
ts = Monday 2037-10-19 17:17:17 AMT
ts = Monday 2037-10-19 17:17:17 AMST
result = Monday 2037-10-26 00:00:00 AMT
wanted = Monday 00:00:00
+1 -1
View File
@@ -189,6 +189,6 @@ int cdb_find(struct cdb *c, char *key, unsigned int len TSRMLS_DC)
/* {{{ cdb_version */
char *cdb_version()
{
return "0.75, $Id$";
return "0.75, $Revision$";
}
/* }}} */
+1 -1
View File
@@ -240,5 +240,5 @@ int cdb_make_finish(struct cdb_make *c TSRMLS_DC)
/* {{{ cdb_make_version */
char *cdb_make_version()
{
return "0.75, $Id$";
return "0.75, $Revision$";
}
+1 -1
View File
@@ -307,7 +307,7 @@ datum flatfile_nextkey(flatfile *dba TSRMLS_DC) {
/* {{{ flatfile_version */
char *flatfile_version()
{
return "1.0, $Id$";
return "1.0, $Revision$";
}
/* }}} */
+1 -1
View File
@@ -43,7 +43,7 @@
/* {{{ inifile_version */
char *inifile_version()
{
return "1.0, $Id$";
return "1.0, $Revision$";
}
/* }}} */
-82
View File
@@ -466,87 +466,6 @@ static int dom_property_exists(zval *object, zval *member, int check_empty TSRML
}
/* }}} */
static HashTable* dom_get_debug_info_helper(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
dom_object *obj = zend_object_store_get_object(object TSRMLS_CC);
HashTable *debug_info,
*prop_handlers = obj->prop_handler,
*std_props;
HashPosition pos;
dom_prop_handler *entry;
zval *object_value,
*null_value;
*is_temp = 1;
ALLOC_HASHTABLE(debug_info);
ZEND_INIT_SYMTABLE_EX(debug_info, 32, 0);
std_props = zend_std_get_properties(object TSRMLS_CC);
zend_hash_copy(debug_info, std_props, (copy_ctor_func_t)zval_add_ref,
NULL, sizeof(zval*));
if (!prop_handlers) {
return debug_info;
}
ALLOC_INIT_ZVAL(object_value);
ZVAL_STRING(object_value, "(object value omitted)", 1);
ALLOC_INIT_ZVAL(null_value);
ZVAL_NULL(null_value);
for (zend_hash_internal_pointer_reset_ex(prop_handlers, &pos);
zend_hash_get_current_data_ex(prop_handlers, (void **)&entry, &pos)
== SUCCESS;
zend_hash_move_forward_ex(prop_handlers, &pos)) {
zval *value;
char *string_key = NULL;
uint string_length = 0;
ulong num_key;
if (entry->read_func(obj, &value TSRMLS_CC) == FAILURE) {
continue;
}
if (zend_hash_get_current_key_ex(prop_handlers, &string_key,
&string_length, &num_key, 0, &pos) != HASH_KEY_IS_STRING) {
continue;
}
if (value == EG(uninitialized_zval_ptr)) {
value = null_value;
} else if (Z_TYPE_P(value) == IS_OBJECT) {
/* these are zvalues create on demand, with refcount and is_ref
* status left in an uninitalized stated */
zval_dtor(value);
efree(value);
value = object_value;
} else {
/* see comment above */
Z_SET_REFCOUNT_P(value, 0);
Z_UNSET_ISREF_P(value);
}
zval_add_ref(&value);
zend_hash_add(debug_info, string_key, string_length,
&value, sizeof(zval *), NULL);
}
zval_ptr_dtor(&null_value);
zval_ptr_dtor(&object_value);
return debug_info;
}
/* }}} */
static HashTable* dom_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
return dom_get_debug_info_helper(object, is_temp TSRMLS_CC);
}
/* }}} */
void *php_dom_export_node(zval *object TSRMLS_DC) /* {{{ */
{
php_libxml_node_object *intern;
@@ -667,7 +586,6 @@ PHP_MINIT_FUNCTION(dom)
dom_object_handlers.get_property_ptr_ptr = dom_get_property_ptr_ptr;
dom_object_handlers.clone_obj = dom_objects_store_clone_obj;
dom_object_handlers.has_property = dom_property_exists;
dom_object_handlers.get_debug_info = dom_get_debug_info;
zend_hash_init(&classes, 0, NULL, NULL, 1);
@@ -8,7 +8,8 @@ Eric Lee Stewart <ericleestewart@gmail.com>
--FILE--
<?php
$fragment = new DOMDocumentFragment();
var_dump(get_class($fragment));
var_dump($fragment);
?>
--EXPECT--
string(19) "DOMDocumentFragment"
--EXPECTF--
object(DOMDocumentFragment)#%d (%d) {
}
@@ -19,7 +19,7 @@ if(!$dom) {
$element = $dom->documentElement;
echo "Verify that we have a DOMElement object:\n";
echo get_class($element), "\n";
var_dump($element);
echo "\nElement should have attributes:\n";
var_dump($element->hasAttributes());
@@ -28,22 +28,24 @@ $nodelist=$dom->getElementsByTagName('tbody') ;
$element = $nodelist->item(0);
echo "\nVerify that we have a DOMElement object:\n";
echo get_class($element), "\n";
var_dump($element);
echo "\nElement should have no attributes:\n";
var_dump($element->hasAttributes());
var_dump($element->hasAttributes())
?>
--EXPECTF--
Verify that we have a DOMElement object:
DOMElement
object(DOMElement)#%d (0) {
}
Element should have attributes:
bool(true)
Verify that we have a DOMElement object:
DOMElement
object(DOMElement)#%d (0) {
}
Element should have no attributes:
bool(false)
+12 -7
View File
@@ -29,7 +29,7 @@ EOXML;
function dumpcourse($current) {
$title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title";
echo "Course: $title:";echo(get_class($current)), "\n";
echo "Course: $title:";var_dump($current);
echo "~";var_dump($current->textContent);
}
@@ -75,7 +75,8 @@ for ($index = 0; $index < $children->length; $index++) {
--EXPECTF--
Start cloneNode test
node 0
Course: new title3:DOMElement
Course: new title3:object(DOMElement)#6 (0) {
}
~string(24) "
c1n1
@@ -83,7 +84,8 @@ Course: new title3:DOMElement
"
node 1
Course: two:DOMElement
Course: two:object(DOMElement)#3 (0) {
}
~string(24) "
c2n1
@@ -91,10 +93,12 @@ Course: two:DOMElement
"
node 2
Course: new title default:DOMElement
Course: new title default:object(DOMElement)#4 (0) {
}
~string(0) ""
node 3
Course: new title true:DOMElement
Course: new title true:object(DOMElement)#7 (0) {
}
~string(24) "
c1n1
@@ -102,5 +106,6 @@ Course: new title true:DOMElement
"
node 4
Course: new title false:DOMElement
~string(0) ""
Course: new title false:object(DOMElement)#8 (0) {
}
~string(0) ""
+16 -9
View File
@@ -29,7 +29,7 @@ EOXML;
function dumpcourse($current) {
$title = ($current->nodeType != XML_TEXT_NODE && $current->hasAttribute('title')) ? $current->getAttribute('title'):"no title";
echo "Course: $title:";echo get_class($current), "\n";
echo "Course: $title:";var_dump($current);
echo "~";var_dump($current->textContent);
}
@@ -60,11 +60,13 @@ for ($index = 0; $index < $children->length; $index++) {
--EXPECTF--
orignal has 5 nodes
node 4
Course: no title:DOMText
Course: no title:object(DOMText)#4 (0) {
}
~string(1) "
"
node 3
Course: two:DOMElement
Course: two:object(DOMElement)#5 (0) {
}
~string(24) "
c2n1
@@ -72,11 +74,13 @@ Course: two:DOMElement
"
node 2
Course: no title:DOMText
Course: no title:object(DOMText)#6 (0) {
}
~string(2) "
"
node 1
Course: one:DOMElement
Course: one:object(DOMElement)#4 (0) {
}
~string(24) "
c1n1
@@ -84,12 +88,14 @@ Course: one:DOMElement
"
node 0
Course: no title:DOMText
Course: no title:object(DOMText)#5 (0) {
}
~string(2) "
"
after text removed it now has 2 nodes
node 0
Course: one:DOMElement
Course: one:object(DOMElement)#3 (0) {
}
~string(24) "
c1n1
@@ -97,10 +103,11 @@ Course: one:DOMElement
"
node 1
Course: two:DOMElement
Course: two:object(DOMElement)#4 (0) {
}
~string(24) "
c2n1
c2n2
"
"
+4 -3
View File
@@ -7,7 +7,7 @@ Bug #42082 (NodeList length zero should be empty)
$doc = new DOMDocument();
$xpath = new DOMXPath($doc);
$nodes = $xpath->query('*');
echo get_class($nodes), "\n";
var_dump($nodes);
var_dump($nodes->length);
$length = $nodes->length;
var_dump(empty($nodes->length), empty($length));
@@ -18,7 +18,8 @@ var_dump(empty($doc->nodeType), empty($doc->firstChild->nodeType))
?>
===DONE===
--EXPECTF--
DOMNodeList
object(DOMNodeList)#%d (0) {
}
int(0)
bool(true)
bool(true)
@@ -28,4 +29,4 @@ bool(true)
bool(false)
bool(false)
===DONE===
+3 -3
View File
@@ -6,9 +6,9 @@ Bug #52656 (DOMCdataSection does not work with splitText).
<?php
$CData = new DOMCdataSection('splithere!');
$CDataSplit = $CData->splitText(5);
echo get_class($CDataSplit), "\n";
var_dump($CDataSplit->data);
var_dump($CDataSplit, $CDataSplit->data);
?>
--EXPECT--
DOMText
object(DOMText)#2 (0) {
}
string(5) "here!"
+3 -2
View File
@@ -17,13 +17,14 @@ $doc = new DOMDocument();
$doc->loadXML($xml, LIBXML_NOENT);
$n = $doc->doctype;
$doc->removeChild($n);
echo get_class($n), "\n";
var_dump($n);
print $doc->saveXML();
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
DOMDocumentType
object(DOMDocumentType)#%d (0) {
}
<?xml version="1.0" encoding="utf-8"?>
<set><foo>footext</foo><bar>bartext</bar></set>
===DONE===
+3 -6
View File
@@ -12,11 +12,7 @@ print "--- Catch exception with try/catch\n";
try {
$rootNode->appendChild($rootNode);
} catch (domexception $e) {
ob_start();
var_dump($e);
$contents = ob_get_contents();
ob_end_clean();
echo preg_replace('/object\(DOMElement\).+\{.*?\}/s', 'DOMElement', $contents);
}
print "--- Don't catch exception with try/catch\n";
$rootNode->appendChild($rootNode);
@@ -51,7 +47,8 @@ object(DOMException)#%d (%d) {
["args"]=>
array(1) {
[0]=>
DOMElement
object(DOMElement)#%d (0) {
}
}
}
}
@@ -64,6 +61,6 @@ object(DOMException)#%d (%d) {
Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
Stack trace:
#0 %sdom003.php(%d): DOMNode->appendChild(Object(DOMElement))
#0 %sdom003.php(13): DOMNode->appendChild(Object(DOMElement))
#1 {main}
thrown in %sdom003.php on line %d
+7 -4
View File
@@ -23,21 +23,24 @@ $children = $root->childNodes;
for ($index = 0; $index < $children->length; $index++) {
echo "--- child $index ---\n";
$current = $children->item($index);
echo get_class($current), "\n";
var_dump($current);
var_dump($current->textContent);
}
--EXPECTF--
bool(true)
--- child 0 ---
DOMText
object(DOMText)#%d (0) {
}
string(2) "
"
--- child 1 ---
DOMComment
object(DOMComment)#%d (0) {
}
string(14) " Hello World! "
--- child 2 ---
DOMText
object(DOMText)#%d (0) {
}
string(1) "
"
+3 -2
View File
@@ -20,13 +20,14 @@ $children = $root->childNodes;
for ($index = 0; $index < $children->length; $index++) {
echo "--- child $index ---\n";
$current = $children->item($index);
echo get_class($current), "\n";
var_dump($current);
var_dump($current->textContent);
}
--EXPECTF--
bool(true)
--- child 0 ---
DOMComment
object(DOMComment)#%d (0) {
}
string(14) " Hello World! "
+4 -9
View File
@@ -2,8 +2,6 @@
Test: setAttributeNode()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
error_reporting = E_ALL & ~E_WARNING
--FILE--
<?php
@@ -26,13 +24,9 @@ $dom2 = new DOMDocument();
$dom2->loadXML($xml2);
$root2 = $dom2->documentElement;
try {
$root2->setAttributeNode($attr);
$root2->setAttributeNode($attr);
} catch (domexception $e) {
ob_start();
var_dump($e);
$contents = ob_get_contents();
ob_end_clean();
echo preg_replace('/object\(DOMAttr\).+\{.*?\}/s', 'DOMAttr', $contents);
var_dump($e);
}
?>
@@ -63,7 +57,8 @@ object(DOMException)#%d (7) {
["args"]=>
array(1) {
[0]=>
DOMAttr
object(DOMAttr)#%d (0) {
}
}
}
}
@@ -1,59 +0,0 @@
--TEST--
Objects of DOM extension: debug info object handler.
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$xml = <<<XML
<foo>
<bar>foobar</bar>
</foo>
XML;
$d = new domdocument;
$d->dynamicProperty = new stdclass;
$d->loadXML($xml);
print_r($d);
--EXPECTF--
DOMDocument Object
(
[dynamicProperty] => stdClass Object
(
)
[doctype] =>
[implementation] => (object value omitted)
[documentElement] => (object value omitted)
[actualEncoding] =>
[encoding] =>
[xmlEncoding] =>
[standalone] => 1
[xmlStandalone] => 1
[version] => 1.0
[xmlVersion] => 1.0
[strictErrorChecking] => 1
[documentURI] => %s
[config] =>
[formatOutput] =>
[validateOnParse] =>
[resolveExternals] =>
[preserveWhiteSpace] => 1
[recover] =>
[substituteEntities] =>
[nodeName] => #document
[nodeValue] =>
[nodeType] => 9
[parentNode] =>
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[attributes] =>
[ownerDocument] =>
[namespaceURI] =>
[prefix] =>
[localName] =>
[baseURI] => %s
[textContent] =>
foobar
)
+9 -6
View File
@@ -18,23 +18,26 @@ $doc->registerNodeClass('DOMElement', 'myElement');
$doc->appendChild(new DOMElement('root'));
$root = $doc->documentElement;
$root->setAttribute('a', 'a1');
echo get_class($root), "\n";
var_dump($root);
print $root->testit()."\n";
$attr = $root->getAttributeNode('a');
echo get_class($attr), "\n";
var_dump($attr);
print $attr->testit()."\n";
unset($attr);
$doc->registerNodeClass('DOMAttr', NULL);
$attr = $root->getAttributeNode('a');
echo get_class($attr), "\n";
var_dump($attr);
print $attr->testit()."\n";
?>
--EXPECTF--
myElement
object(myElement)#%d (0) {
}
HELLO Element
myAttribute
object(myAttribute)#%d (0) {
}
HELLO Attribute
DOMAttr
object(DOMAttr)#%d (0) {
}
Fatal error: Call to undefined method DOMAttr::testit() in %s on line 25
+1 -1
View File
@@ -326,7 +326,7 @@ PHP_MINFO_FUNCTION(enchant)
#elif defined(HAVE_ENCHANT_BROKER_SET_PARAM)
php_info_print_table_row(2, "Libenchant Version", "1.5.0 or later");
#endif
php_info_print_table_row(2, "Revision", "$Id$");
php_info_print_table_row(2, "Revision", "$Revision$");
php_info_print_table_end();
php_info_print_table_start();
+81216 -114243
View File
File diff suppressed because it is too large. Load diff
+8 -35
View File
@@ -76,9 +76,9 @@ struct finfo_object {
} \
}
/* {{{ finfo_objects_free
/* {{{ finfo_objects_dtor
*/
static void finfo_objects_free(void *object TSRMLS_DC)
static void finfo_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC)
{
struct finfo_object *intern = (struct finfo_object *) object;
@@ -108,8 +108,7 @@ PHP_FILEINFO_API zend_object_value finfo_objects_new(zend_class_entry *class_typ
intern->ptr = NULL;
retval.handle = zend_objects_store_put(intern, NULL,
finfo_objects_free, NULL TSRMLS_CC);
retval.handle = zend_objects_store_put(intern, finfo_objects_dtor, NULL, NULL TSRMLS_CC);
retval.handlers = (zend_object_handlers *) &finfo_object_handlers;
return retval;
@@ -277,15 +276,6 @@ PHP_MINFO_FUNCTION(fileinfo)
}
/* }}} */
#define FILEINFO_DESTROY_OBJECT(object) \
do { \
if (object) { \
zend_object_store_ctor_failed(object TSRMLS_CC); \
zval_dtor(object); \
ZVAL_NULL(object); \
} \
} while (0)
/* {{{ proto resource finfo_open([int options [, string arg]])
Create a new fileinfo resource. */
PHP_FUNCTION(finfo_open)
@@ -298,7 +288,6 @@ PHP_FUNCTION(finfo_open)
char resolved_path[MAXPATHLEN];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &options, &file, &file_len) == FAILURE) {
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
@@ -316,11 +305,9 @@ PHP_FUNCTION(finfo_open)
file = NULL;
} else if (file && *file) { /* user specified file, perform open_basedir checks */
if (strlen(file) != file_len) {
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
if (!VCWD_REALPATH(file, resolved_path)) {
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
file = resolved_path;
@@ -330,7 +317,6 @@ PHP_FUNCTION(finfo_open)
#else
if (php_check_open_basedir(file TSRMLS_CC)) {
#endif
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
}
@@ -343,23 +329,21 @@ PHP_FUNCTION(finfo_open)
if (finfo->magic == NULL) {
efree(finfo);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%ld'.", options);
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
RETURN_FALSE;
}
if (magic_load(finfo->magic, file) == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to load magic database at '%s'.", file);
magic_close(finfo->magic);
efree(finfo);
FILEINFO_DESTROY_OBJECT(object);
RETURN_FALSE;
}
}
if (object) {
FILEINFO_REGISTER_OBJECT(object, finfo);
} else {
ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo);
}
}
}
/* }}} */
@@ -515,22 +499,11 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_CC);
if (wrap) {
php_stream *stream;
php_stream_context *context = php_stream_context_from_zval(zcontext, 0);
#ifdef PHP_WIN32
if (php_stream_stat_path_ex(buffer, 0, &ssb, context) == SUCCESS) {
if (ssb.sb.st_mode & S_IFDIR) {
ret_val = mime_directory;
goto common;
}
}
#endif
#if PHP_API_VERSION < 20100412
stream = php_stream_open_wrapper_ex(buffer, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
php_stream *stream = php_stream_open_wrapper_ex(buffer, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
#else
stream = php_stream_open_wrapper_ex(buffer, "rb", REPORT_ERRORS, NULL, context);
php_stream *stream = php_stream_open_wrapper_ex(buffer, "rb", REPORT_ERRORS, NULL, context);
#endif
if (!stream) {
File diff suppressed because it is too large. Load diff
+81 -272
View File
@@ -34,7 +34,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: apprentice.c,v 1.173 2011/12/08 12:38:24 rrt Exp $")
FILE_RCSID("@(#)$File: apprentice.c,v 1.151 2009/03/18 15:19:23 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -89,6 +89,10 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.173 2011/12/08 12:38:24 rrt Exp $")
#define MAP_FILE 0
#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
struct magic_entry {
struct magic *mp;
uint32_t cont_count;
@@ -110,7 +114,6 @@ private void eatsize(const char **);
private int apprentice_1(struct magic_set *, const char *, int, struct mlist *);
private size_t apprentice_magic_strength(const struct magic *);
private int apprentice_sort(const void *, const void *);
private void apprentice_list(struct mlist *, int );
private int apprentice_load(struct magic_set *, struct magic **, uint32_t *,
const char *, int);
private void byteswap(struct magic *, uint32_t);
@@ -297,13 +300,6 @@ apprentice_1(struct magic_set *ms, const char *fn, int action,
ml->next = mlist;
mlist->prev = ml;
if (action == FILE_LIST) {
printf("Binary patterns:\n");
apprentice_list(mlist, BINTEST);
printf("Text patterns:\n");
apprentice_list(mlist, TEXTTEST);
}
return 0;
}
@@ -337,11 +333,6 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
char *p, *mfn;
int file_err, errs = -1;
struct mlist *mlist;
/* XXX disabling default magic loading so the compiled in data is used */
#if 0
if ((fn = magic_getpath(fn, action)) == NULL)
return NULL;
#endif
init_file_tables();
@@ -538,43 +529,6 @@ apprentice_sort(const void *a, const void *b)
return 1;
}
/*
* Shows sorted patterns list in the order which is used for the matching
*/
private void
apprentice_list(struct mlist *mlist, int mode)
{
uint32_t magindex = 0;
struct mlist *ml;
for (ml = mlist->next; ml != mlist; ml = ml->next) {
for (magindex = 0; magindex < ml->nmagic; magindex++) {
struct magic *m = &ml->magic[magindex];
if ((m->flag & mode) != mode) {
/* Skip sub-tests */
while (magindex + 1 < ml->nmagic &&
ml->magic[magindex + 1].cont_level != 0)
++magindex;
continue; /* Skip to next top-level test*/
}
/*
* Try to iterate over the tree until we find item with
* description/mimetype.
*/
while (magindex + 1 < ml->nmagic &&
ml->magic[magindex + 1].cont_level != 0 &&
*ml->magic[magindex].desc == '\0' &&
*ml->magic[magindex].mimetype == '\0')
magindex++;
printf("Strength = %3" SIZE_T_FORMAT "u : %s [%s]\n",
apprentice_magic_strength(m),
ml->magic[magindex].desc,
ml->magic[magindex].mimetype);
}
}
}
private void
set_test_type(struct magic *mstart, struct magic *m)
{
@@ -610,35 +564,19 @@ set_test_type(struct magic *mstart, struct magic *m)
case FILE_DOUBLE:
case FILE_BEDOUBLE:
case FILE_LEDOUBLE:
mstart->flag |= BINTEST;
break;
case FILE_STRING:
case FILE_PSTRING:
case FILE_BESTRING16:
case FILE_LESTRING16:
/* Allow text overrides */
if (mstart->str_flags & STRING_TEXTTEST)
mstart->flag |= TEXTTEST;
else
mstart->flag |= BINTEST;
/* binary test, set flag */
mstart->flag |= BINTEST;
break;
case FILE_REGEX:
case FILE_SEARCH:
/* Check for override */
if (mstart->str_flags & STRING_BINTEST)
mstart->flag |= BINTEST;
if (mstart->str_flags & STRING_TEXTTEST)
mstart->flag |= TEXTTEST;
if (mstart->flag & (TEXTTEST|BINTEST))
break;
/* binary test if pattern is not text */
if (file_looks_utf8(m->value.us, (size_t)m->vallen, NULL,
NULL) <= 0)
mstart->flag |= BINTEST;
else
mstart->flag |= TEXTTEST;
break;
case FILE_DEFAULT:
/* can't deduce anything; we shouldn't see this at the
@@ -659,8 +597,8 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
struct magic_entry **marray, uint32_t *marraycount)
{
char buffer[BUFSIZ + 1];
char *line = NULL;
size_t len;
char *line;
size_t line_len;
size_t lineno = 0;
php_stream *stream;
@@ -678,31 +616,31 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
file_error(ms, errno, "cannot read magic file `%s'",
fn);
(*errs)++;
return;
}
} else {
/* read and parse this file */
#if (PHP_MAJOR_VERSION < 6)
for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &len)) != NULL; ms->line++) {
for (ms->line = 1; (line = php_stream_get_line(stream, buffer , BUFSIZ, &line_len)) != NULL; ms->line++) {
#else
for (ms->line = 1; (line = php_stream_get_line(stream, ZSTR(buffer), BUFSIZ, &len)) != NULL; ms->line++) {
for (ms->line = 1; (line = php_stream_get_line(stream, ZSTR(buffer), BUFSIZ, &line_len)) != NULL; ms->line++) {
#endif
if (len == 0) /* null line, garbage, etc */
continue;
if (line[len - 1] == '\n') {
lineno++;
line[len - 1] = '\0'; /* delete newline */
}
switch (line[0]) {
case '\0': /* empty, do not parse */
case '#': /* comment, do not parse */
continue;
case '!':
if (line[1] == ':') {
if (line_len == 0) /* null line, garbage, etc */
continue;
if (line[line_len - 1] == '\n') {
lineno++;
line[line_len - 1] = '\0'; /* delete newline */
}
if (line[0] == '\0') /* empty, do not parse */
continue;
if (line[0] == '#') /* comment, do not parse */
continue;
if (line[0] == '!' && line[1] == ':') {
size_t i;
for (i = 0; bang[i].name != NULL; i++) {
if ((size_t)(len - 2) > bang[i].len &&
if (line_len - 2 > bang[i].len &&
memcmp(bang[i].name, line + 2,
bang[i].len) == 0)
break;
@@ -728,27 +666,18 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
}
continue;
}
/*FALLTHROUGH*/
default:
if (parse(ms, marray, marraycount, line, lineno,
action) != 0)
if (parse(ms, marray, marraycount, line, lineno, action) != 0)
(*errs)++;
break;
}
php_stream_close(stream);
}
php_stream_close(stream);
}
/*
* parse a file or directory of files
* const char *fn: name of magic file or directory
*/
private int
cmpstrp(const void *p1, const void *p2)
{
return strcmp(*(char *const *)p1, *(char *const *)p2);
}
private int
apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
const char *fn, int action)
@@ -756,8 +685,7 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
int errs = 0;
struct magic_entry *marray;
uint32_t marraycount, i, mentrycount = 0, starttest;
size_t files = 0, maxfiles = 0;
char **filearr = NULL, mfn[MAXPATHLEN];
char subfn[MAXPATHLEN];
struct stat st;
DIR *dir;
struct dirent *d;
@@ -777,43 +705,19 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
non-determinism. See Debian bug #488562. */
if (php_sys_stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
dir = opendir(fn);
if (!dir) {
errs++;
goto out;
}
while ((d = readdir(dir)) != NULL) {
if (snprintf(mfn, sizeof(mfn), "%s/%s", fn, d->d_name) < 0) {
file_oomem(ms,
strlen(fn) + strlen(d->d_name) + 2);
errs++;
closedir(dir);
goto out;
}
if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
continue;
}
if (files >= maxfiles) {
size_t mlen;
maxfiles = (maxfiles + 1) * 2;
mlen = maxfiles * sizeof(*filearr);
if ((filearr = CAST(char **,
realloc(filearr, mlen))) == NULL) {
file_oomem(ms, mlen);
closedir(dir);
errs++;
goto out;
if (dir) {
while ((d = readdir(dir)) != NULL) {
snprintf(subfn, sizeof(subfn), "%s/%s",
fn, d->d_name);
if (stat(subfn, &st) == 0 &&
S_ISREG(st.st_mode)) {
load_1(ms, action, subfn, &errs,
&marray, &marraycount);
}
}
filearr[files++] = mfn;
}
closedir(dir);
qsort(filearr, files, sizeof(*filearr), cmpstrp);
for (i = 0; i < files; i++) {
load_1(ms, action, filearr[i], &errs, &marray,
&marraycount);
free(filearr[i]);
}
free(filearr);
closedir(dir);
} else
errs++;
} else
load_1(ms, action, fn, &errs, &marray, &marraycount);
if (errs)
@@ -865,8 +769,7 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
if (marray[i].mp->cont_level == 0)
break;
if (i != marraycount) {
/* XXX - Ugh! */
ms->line = marray[i].mp->lineno;
ms->line = marray[i].mp->lineno; /* XXX - Ugh! */
file_magwarn(ms,
"level 0 \"default\" did not sort last");
}
@@ -977,11 +880,6 @@ string_modifier_check(struct magic_set *ms, struct magic *m)
if ((ms->flags & MAGIC_CHECK) == 0)
return 0;
if (m->type != FILE_PSTRING && (m->str_flags & PSTRING_LEN) != 0) {
file_magwarn(ms,
"'/BHhLl' modifiers are only allowed for pascal strings\n");
return -1;
}
switch (m->type) {
case FILE_BESTRING16:
case FILE_LESTRING16:
@@ -1010,14 +908,14 @@ string_modifier_check(struct magic_set *ms, struct magic *m)
}
break;
case FILE_REGEX:
if ((m->str_flags & STRING_COMPACT_WHITESPACE) != 0) {
if ((m->str_flags & STRING_COMPACT_BLANK) != 0) {
file_magwarn(ms, "'/%c' not allowed on regex\n",
CHAR_COMPACT_WHITESPACE);
CHAR_COMPACT_BLANK);
return -1;
}
if ((m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE) != 0) {
if ((m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) != 0) {
file_magwarn(ms, "'/%c' not allowed on regex\n",
CHAR_COMPACT_OPTIONAL_WHITESPACE);
CHAR_COMPACT_OPTIONAL_BLANK);
return -1;
}
break;
@@ -1170,7 +1068,7 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
size_t cnt = me->max_count + ALLOC_CHUNK;
nm = erealloc(me->mp, sizeof(*nm) * cnt);
me->mp = m = nm;
me->max_count = CAST(uint32_t, cnt);
me->max_count = cnt;
}
m = &me->mp[me->cont_count++];
(void)memset(m, 0, sizeof(*m));
@@ -1196,7 +1094,7 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
m->cont_level = 0;
me->cont_count = 1;
}
m->lineno = CAST(uint32_t, lineno);
m->lineno = lineno;
if (*l == '&') { /* m->cont_level == 0 checked below. */
++l; /* step over */
@@ -1344,7 +1242,8 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
++l;
}
m->str_range = 0;
m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0;
m->str_flags = 0;
m->num_mask = 0;
if ((op = get_op(*l)) != -1) {
if (!IS_LIBMAGIC_STRING(m->type)) {
uint64_t val;
@@ -1368,20 +1267,18 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
file_magwarn(ms,
"multiple ranges");
have_range = 1;
m->str_range = CAST(uint32_t,
strtoul(l, &t, 0));
m->str_range = strtoul(l, &t, 0);
if (m->str_range == 0)
file_magwarn(ms,
"zero range");
l = t - 1;
break;
case CHAR_COMPACT_WHITESPACE:
m->str_flags |=
STRING_COMPACT_WHITESPACE;
case CHAR_COMPACT_BLANK:
m->str_flags |= STRING_COMPACT_BLANK;
break;
case CHAR_COMPACT_OPTIONAL_WHITESPACE:
case CHAR_COMPACT_OPTIONAL_BLANK:
m->str_flags |=
STRING_COMPACT_OPTIONAL_WHITESPACE;
STRING_COMPACT_OPTIONAL_BLANK;
break;
case CHAR_IGNORE_LOWERCASE:
m->str_flags |= STRING_IGNORE_LOWERCASE;
@@ -1392,48 +1289,11 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
case CHAR_REGEX_OFFSET_START:
m->str_flags |= REGEX_OFFSET_START;
break;
case CHAR_BINTEST:
m->str_flags |= STRING_BINTEST;
break;
case CHAR_TEXTTEST:
m->str_flags |= STRING_TEXTTEST;
break;
case CHAR_PSTRING_1_LE:
if (m->type != FILE_PSTRING)
goto bad;
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_1_LE;
break;
case CHAR_PSTRING_2_BE:
if (m->type != FILE_PSTRING)
goto bad;
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_2_BE;
break;
case CHAR_PSTRING_2_LE:
if (m->type != FILE_PSTRING)
goto bad;
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_2_LE;
break;
case CHAR_PSTRING_4_BE:
if (m->type != FILE_PSTRING)
goto bad;
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_BE;
break;
case CHAR_PSTRING_4_LE:
if (m->type != FILE_PSTRING)
goto bad;
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_LE;
break;
case CHAR_PSTRING_LENGTH_INCLUDES_ITSELF:
if (m->type != FILE_PSTRING)
goto bad;
m->str_flags |= PSTRING_LENGTH_INCLUDES_ITSELF;
break;
default:
bad:
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms,
"string extension `%c' "
"invalid", *l);
"string extension `%c' invalid",
*l);
return -1;
}
/* allow multiple '/' for readability */
@@ -1595,8 +1455,7 @@ out:
}
/*
* Parse an Apple CREATOR/TYPE annotation from magic file and put it into
* magic[index - 1]
* Parse an Apple CREATOR/TYPE annotation from magic file and put it into magic[index - 1]
*/
private int
parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line)
@@ -1606,21 +1465,19 @@ parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line)
struct magic *m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
if (m->apple[0] != '\0') {
file_magwarn(ms, "Current entry already has a APPLE type "
"`%.8s', new type `%s'", m->mimetype, l);
file_magwarn(ms, "Current entry already has a APPLE type `%.8s',"
" new type `%s'", m->mimetype, l);
return -1;
}
EATAB;
for (i = 0; *l && ((isascii((unsigned char)*l) &&
isalnum((unsigned char)*l)) || strchr("-+/.", *l)) &&
i < sizeof(m->apple); m->apple[i++] = *l++)
for (i = 0; *l && ((isascii((unsigned char)*l) && isalnum((unsigned char)*l))
|| strchr("-+/.", *l)) && i < sizeof(m->apple); m->apple[i++] = *l++)
continue;
if (i == sizeof(m->apple) && *l) {
/* We don't need to NUL terminate here, printing handles it */
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "APPLE type `%s' truncated %"
SIZE_T_FORMAT "u", line, i);
file_magwarn(ms, "APPLE type `%s' truncated %zu",
line, i);
}
if (i > 0)
@@ -1647,15 +1504,14 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line)
}
EATAB;
for (i = 0; *l && ((isascii((unsigned char)*l) &&
isalnum((unsigned char)*l)) || strchr("-+/.", *l)) &&
i < sizeof(m->mimetype); m->mimetype[i++] = *l++)
for (i = 0; *l && ((isascii((unsigned char)*l) && isalnum((unsigned char)*l))
|| strchr("-+/.", *l)) && i < sizeof(m->mimetype); m->mimetype[i++] = *l++)
continue;
if (i == sizeof(m->mimetype)) {
m->mimetype[sizeof(m->mimetype) - 1] = '\0';
m->desc[sizeof(m->mimetype) - 1] = '\0';
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "MIME type `%s' truncated %"
SIZE_T_FORMAT "u", m->mimetype, i);
file_magwarn(ms, "MIME type `%s' truncated %zu",
m->mimetype, i);
} else
m->mimetype[i] = '\0';
@@ -1944,10 +1800,8 @@ getstr(struct magic_set *ms, struct magic *m, const char *s, int warn)
if (isprint((unsigned char)c)) {
/* Allow escaping of
* ``relations'' */
if (strchr("<>&^=!", c) == NULL
&& (m->type != FILE_REGEX ||
strchr("[]().*?^$|{}", c)
== NULL)) {
if (strchr("<>&^=!", c)
== NULL) {
file_magwarn(ms, "no "
"need to escape "
"`%c'", c);
@@ -2055,9 +1909,9 @@ getstr(struct magic_set *ms, struct magic *m, const char *s, int warn)
}
out:
*p = '\0';
m->vallen = CAST(unsigned char, (p - origp));
m->vallen = p - origp;
if (m->type == FILE_PSTRING)
m->vallen += (unsigned char)file_pstring_length_size(m);
m->vallen++;
return s;
}
@@ -2087,15 +1941,14 @@ file_showstr(FILE *fp, const char *s, size_t len)
char c;
for (;;) {
c = *s++;
if (len == ~0U) {
c = *s++;
if (c == '\0')
break;
}
else {
if (len-- == 0)
break;
c = *s++;
}
if (c >= 040 && c <= 0176) /* TODO isprint && !iscntrl */
(void) fputc(c, fp);
@@ -2217,11 +2070,11 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
}
mm = emalloc((size_t)st.sb.st_size);
ret = 1;
if (php_stream_read(stream, mm, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) {
file_badread(ms);
goto error1;
}
ret = 1;
php_stream_close(stream);
stream = NULL;
@@ -2235,12 +2088,15 @@ internal_loaded:
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 version %d magic "
"files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel,
@@ -2312,8 +2168,9 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp,
dbname = mkdbname(ms, fn, 0);
if (dbname == NULL)
if (dbname == NULL) {
goto out;
}
/* wb+ == O_WRONLY|O_CREAT|O_TRUNC|O_BINARY */
#if PHP_API_VERSION < 20100412
@@ -2487,51 +2344,3 @@ bs1(struct magic *m)
m->num_mask = swap8(m->num_mask);
}
}
protected size_t
file_pstring_length_size(const struct magic *m)
{
switch (m->str_flags & PSTRING_LEN) {
case PSTRING_1_LE:
return 1;
case PSTRING_2_LE:
case PSTRING_2_BE:
return 2;
case PSTRING_4_LE:
case PSTRING_4_BE:
return 4;
default:
abort(); /* Impossible */
return 1;
}
}
protected size_t
file_pstring_get_length(const struct magic *m, const char *s)
{
size_t len = 0;
switch (m->str_flags & PSTRING_LEN) {
case PSTRING_1_LE:
len = *s;
break;
case PSTRING_2_LE:
len = (s[1] << 8) | s[0];
break;
case PSTRING_2_BE:
len = (s[0] << 8) | s[1];
break;
case PSTRING_4_LE:
len = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0];
break;
case PSTRING_4_BE:
len = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
break;
default:
abort(); /* Impossible */
}
if (m->str_flags & PSTRING_LENGTH_INCLUDES_ITSELF)
len -= file_pstring_length_size(m);
return len;
}
+1 -2
View File
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: apptype.c,v 1.13 2011/09/07 21:57:15 christos Exp $")
FILE_RCSID("@(#)$File: apptype.c,v 1.11 2009/02/04 18:24:32 christos Exp $")
#endif /* lint */
#include <stdlib.h>
@@ -72,7 +72,6 @@ file_os2_apptype(struct magic_set *ms, const char *fn, const void *buf,
if (fwrite(buf, 1, nb, fp) != nb) {
file_error(ms, errno, "cannot write tmp file `%s'",
path);
(void)fclose(fp);
return -1;
}
(void)fclose(fp);
+79 -50
View File
@@ -26,7 +26,8 @@
* SUCH DAMAGE.
*/
/*
* ASCII magic -- try to detect text encoding.
* ASCII magic -- file types that we know based on keywords
* that can appear anywhere in the file.
*
* Extensively modified by Eric Fischer <enf@pobox.com> in July, 2000,
* to handle character codes other than ASCII on a unified basis.
@@ -35,7 +36,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: ascmagic.c,v 1.84 2011/12/08 12:38:24 rrt Exp $")
FILE_RCSID("@(#)$File: ascmagic.c,v 1.75 2009/02/03 20:27:51 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -46,11 +47,13 @@ FILE_RCSID("@(#)$File: ascmagic.c,v 1.84 2011/12/08 12:38:24 rrt Exp $")
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "names.h"
#define MAXLINELEN 300 /* longest sane line length */
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
|| (x) == 0x85 || (x) == '\f')
private int ascmatch(const unsigned char *, const unichar *, size_t);
private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t);
private size_t trim_nuls(const unsigned char *, size_t);
@@ -68,8 +71,7 @@ trim_nuls(const unsigned char *buf, size_t nbytes)
}
protected int
file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
int text)
file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
{
unichar *ubuf = NULL;
size_t ulen;
@@ -86,13 +88,17 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
/* If file doesn't look like any sort of text, give up. */
if (file_encoding(ms, buf, nbytes, &ubuf, &ulen, &code, &code_mime,
&type) == 0)
&type) == 0) {
rv = 0;
else
rv = file_ascmagic_with_encoding(ms, buf, nbytes, ubuf, ulen, code,
type, text);
goto done;
}
free(ubuf);
rv = file_ascmagic_with_encoding(ms, buf, nbytes, ubuf, ulen, code,
type);
done:
if (ubuf)
free(ubuf);
return rv;
}
@@ -100,10 +106,11 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
protected int
file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
size_t nbytes, unichar *ubuf, size_t ulen, const char *code,
const char *type, int text)
const char *type)
{
unsigned char *utf8_buf = NULL, *utf8_end;
size_t mlen, i;
const struct names *p;
int rv = -1;
int mime = ms->flags & MAGIC_MIME;
@@ -118,7 +125,6 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
int n_lf = 0;
int n_cr = 0;
int n_nel = 0;
int executable = 0;
size_t last_line_end = (size_t)-1;
int has_long_lines = 0;
@@ -134,21 +140,54 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
goto done;
}
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0) {
/* Convert ubuf to UTF-8 and try text soft magic */
/* malloc size is a conservative overestimate; could be
improved, or at least realloced after conversion. */
mlen = ulen * 6;
utf8_buf = emalloc(mlen);
/* Convert ubuf to UTF-8 and try text soft magic */
/* malloc size is a conservative overestimate; could be
improved, or at least realloced after conversion. */
mlen = ulen * 6;
utf8_buf = emalloc(mlen);
if ((utf8_end = encode_utf8(utf8_buf, mlen, ubuf, ulen))
== NULL)
goto done;
if ((rv = file_softmagic(ms, utf8_buf,
(size_t)(utf8_end - utf8_buf), TEXTTEST, text)) == 0)
rv = -1;
if ((utf8_end = encode_utf8(utf8_buf, mlen, ubuf, ulen)) == NULL)
goto done;
if ((rv = file_softmagic(ms, utf8_buf, (size_t)(utf8_end - utf8_buf),
TEXTTEST)) != 0)
goto done;
else
rv = -1;
/* look for tokens from names.h - this is expensive! */
if ((ms->flags & MAGIC_NO_CHECK_TOKENS) != 0)
goto subtype_identified;
i = 0;
while (i < ulen) {
size_t end;
/* skip past any leading space */
while (i < ulen && ISSPC(ubuf[i]))
i++;
if (i >= ulen)
break;
/* find the next whitespace */
for (end = i + 1; end < nbytes; end++)
if (ISSPC(ubuf[end]))
break;
/* compare the word thus isolated against the token list */
for (p = names; p < names + NNAMES; p++) {
if (ascmatch((const unsigned char *)p->name, ubuf + i,
end - i)) {
subtype = types[p->type].human;
subtype_mime = types[p->type].mime;
goto subtype_identified;
}
}
i = end;
}
subtype_identified:
/* Now try to discover other details about the file. */
for (i = 0; i < ulen; i++) {
if (ubuf[i] == '\n') {
@@ -191,7 +230,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
goto done;
}
if (mime) {
if (!file_printedlen(ms) && (mime & MAGIC_MIME_TYPE) != 0) {
if ((mime & MAGIC_MIME_TYPE) != 0) {
if (subtype_mime) {
if (file_printf(ms, "%s", subtype_mime) == -1)
goto done;
@@ -201,28 +240,6 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
}
}
} else {
if (file_printedlen(ms)) {
switch (file_replace(ms, " text$", ", ")) {
case 0:
switch (file_replace(ms, " text executable$",
", ")) {
case 0:
if (file_printf(ms, ", ") == -1)
goto done;
case -1:
goto done;
default:
executable = 1;
break;
}
break;
case -1:
goto done;
default:
break;
}
}
if (file_printf(ms, "%s", code) == -1)
goto done;
@@ -234,10 +251,6 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
if (file_printf(ms, " %s", type) == -1)
goto done;
if (executable)
if (file_printf(ms, " executable") == -1)
goto done;
if (has_long_lines)
if (file_printf(ms, ", with very long lines") == -1)
goto done;
@@ -300,6 +313,22 @@ done:
return rv;
}
private int
ascmatch(const unsigned char *s, const unichar *us, size_t ulen)
{
size_t i;
for (i = 0; i < ulen; i++) {
if (s[i] != us[i])
return 0;
}
if (s[i])
return 0;
else
return 1;
}
/*
* Encode Unicode string as UTF-8, returning pointer to character
* after end of string, or NULL if an invalid character is found.
+138 -249
View File
@@ -24,18 +24,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Parse Composite Document Files, the format used in Microsoft Office
* document files before they switched to zipped XML.
* Parse composite document files, the format used in Microsoft Office
* document files before they switched to zipped xml.
* Info from: http://sc.openoffice.org/compdocfileformat.pdf
*
* N.B. This is the "Composite Document File" format, and not the
* "Compound Document Format", nor the "Channel Definition Format".
*/
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012/02/20 22:35:29 christos Exp $")
FILE_RCSID("@(#)$File: cdf.c,v 1.30 2009/05/06 14:29:47 christos Exp $")
#endif
#include <assert.h>
@@ -57,9 +54,6 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012/02/20 22:35:29 christos Exp $")
#include <string.h>
#include <time.h>
#include <ctype.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef EFTYPE
#define EFTYPE EINVAL
@@ -67,6 +61,10 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012/02/20 22:35:29 christos Exp $")
#include "cdf.h"
#ifndef __arraycount
#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
#endif
#ifdef CDF_DEBUG
#define DPRINTF(a) printf a, fflush(stdout)
#else
@@ -80,21 +78,19 @@ static union {
#define NEED_SWAP (cdf_bo.u == (uint32_t)0x01020304)
#define CDF_TOLE8(x) ((uint64_t)(NEED_SWAP ? _cdf_tole8(x) : (uint64_t)(x)))
#define CDF_TOLE4(x) ((uint32_t)(NEED_SWAP ? _cdf_tole4(x) : (uint32_t)(x)))
#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? _cdf_tole2(x) : (uint16_t)(x)))
#define CDF_GETUINT32(x, y) cdf_getuint32(x, y)
#define CDF_TOLE8(x) (NEED_SWAP ? cdf_tole8(x) : (uint64_t)(x))
#define CDF_TOLE4(x) (NEED_SWAP ? cdf_tole4(x) : (uint32_t)(x))
#define CDF_TOLE2(x) (NEED_SWAP ? cdf_tole2(x) : (uint16_t)(x))
/*
* swap a short
*/
static uint16_t
_cdf_tole2(uint16_t sv)
uint16_t
cdf_tole2(uint16_t sv)
{
uint16_t rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
d[0] = s[1];
d[1] = s[0];
return rv;
@@ -103,12 +99,12 @@ _cdf_tole2(uint16_t sv)
/*
* swap an int
*/
static uint32_t
_cdf_tole4(uint32_t sv)
uint32_t
cdf_tole4(uint32_t sv)
{
uint32_t rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
d[0] = s[3];
d[1] = s[2];
d[2] = s[1];
@@ -119,12 +115,12 @@ _cdf_tole4(uint32_t sv)
/*
* swap a quad
*/
static uint64_t
_cdf_tole8(uint64_t sv)
uint64_t
cdf_tole8(uint64_t sv)
{
uint64_t rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
d[0] = s[7];
d[1] = s[6];
d[2] = s[5];
@@ -136,41 +132,11 @@ _cdf_tole8(uint64_t sv)
return rv;
}
/*
* grab a uint32_t from a possibly unaligned address, and return it in
* the native host order.
*/
static uint32_t
cdf_getuint32(const uint8_t *p, size_t offs)
{
uint32_t rv;
(void)memcpy(&rv, p + offs * sizeof(uint32_t), sizeof(rv));
return CDF_TOLE4(rv);
}
#define CDF_UNPACK(a) \
(void)memcpy(&(a), &buf[len], sizeof(a)), len += sizeof(a)
#define CDF_UNPACKA(a) \
(void)memcpy((a), &buf[len], sizeof(a)), len += sizeof(a)
uint16_t
cdf_tole2(uint16_t sv)
{
return CDF_TOLE2(sv);
}
uint32_t
cdf_tole4(uint32_t sv)
{
return CDF_TOLE4(sv);
}
uint64_t
cdf_tole8(uint64_t sv)
{
return CDF_TOLE8(sv);
}
void
cdf_swap_header(cdf_header_t *h)
{
@@ -189,15 +155,15 @@ cdf_swap_header(cdf_header_t *h)
h->h_min_size_standard_stream =
CDF_TOLE4(h->h_min_size_standard_stream);
h->h_secid_first_sector_in_short_sat =
CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_short_sat);
CDF_TOLE4(h->h_secid_first_sector_in_short_sat);
h->h_num_sectors_in_short_sat =
CDF_TOLE4(h->h_num_sectors_in_short_sat);
h->h_secid_first_sector_in_master_sat =
CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_master_sat);
CDF_TOLE4(h->h_secid_first_sector_in_master_sat);
h->h_num_sectors_in_master_sat =
CDF_TOLE4(h->h_num_sectors_in_master_sat);
for (i = 0; i < __arraycount(h->h_master_sat); i++)
h->h_master_sat[i] = CDF_TOLE4((uint32_t)h->h_master_sat[i]);
h->h_master_sat[i] = CDF_TOLE4(h->h_master_sat[i]);
}
void
@@ -230,15 +196,15 @@ void
cdf_swap_dir(cdf_directory_t *d)
{
d->d_namelen = CDF_TOLE2(d->d_namelen);
d->d_left_child = CDF_TOLE4((uint32_t)d->d_left_child);
d->d_right_child = CDF_TOLE4((uint32_t)d->d_right_child);
d->d_storage = CDF_TOLE4((uint32_t)d->d_storage);
d->d_left_child = CDF_TOLE4(d->d_left_child);
d->d_right_child = CDF_TOLE4(d->d_right_child);
d->d_storage = CDF_TOLE4(d->d_storage);
d->d_storage_uuid[0] = CDF_TOLE8(d->d_storage_uuid[0]);
d->d_storage_uuid[1] = CDF_TOLE8(d->d_storage_uuid[1]);
d->d_flags = CDF_TOLE4(d->d_flags);
d->d_created = CDF_TOLE8((uint64_t)d->d_created);
d->d_modified = CDF_TOLE8((uint64_t)d->d_modified);
d->d_stream_first_sector = CDF_TOLE4((uint32_t)d->d_stream_first_sector);
d->d_created = CDF_TOLE8(d->d_created);
d->d_modified = CDF_TOLE8(d->d_modified);
d->d_stream_first_sector = CDF_TOLE4(d->d_stream_first_sector);
d->d_size = CDF_TOLE4(d->d_size);
}
@@ -272,18 +238,14 @@ cdf_unpack_dir(cdf_directory_t *d, char *buf)
}
static int
cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
const void *p, size_t tail, int line)
cdf_check_stream_offset(const cdf_stream_t *sst, const void *p, size_t tail)
{
const char *b = (const char *)sst->sst_tab;
const char *e = ((const char *)p) + tail;
(void)&line;
if (e >= b && (size_t)(e - b) < CDF_SEC_SIZE(h) * sst->sst_len)
if (e >= b && (size_t)(e - b) < sst->sst_dirlen * sst->sst_len)
return 0;
DPRINTF(("%d: offset begin %p end %p %" SIZE_T_FORMAT "u"
" >= %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
DPRINTF((stderr, "offset begin %p end %p %zu >= %zu\n", b, e,
(size_t)(e - b), sst->sst_dirlen * sst->sst_len));
errno = EFTYPE;
return -1;
}
@@ -306,10 +268,10 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
if (info->i_fd == -1)
return -1;
if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (off_t)-1)
if (lseek(info->i_fd, off, SEEK_SET) == (off_t)-1)
return -1;
if (FINFO_READ_FUNC(info->i_fd, buf, len) != (ssize_t)len)
if (read(info->i_fd, buf, len) != (ssize_t)len)
return -1;
return (ssize_t)len;
@@ -326,8 +288,7 @@ cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
cdf_unpack_header(h, buf);
cdf_swap_header(h);
if (h->h_magic != CDF_MAGIC) {
DPRINTF(("Bad magic 0x%" INT64_T_FORMAT "x != 0x%"
INT64_T_FORMAT "x\n",
DPRINTF(("Bad magic 0x%llx != 0x%llx\n",
(unsigned long long)h->h_magic,
(unsigned long long)CDF_MAGIC));
goto out;
@@ -352,27 +313,18 @@ ssize_t
cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,
const cdf_header_t *h, cdf_secid_t id)
{
size_t ss = CDF_SEC_SIZE(h);
size_t pos = CDF_SEC_POS(h, id);
assert(ss == len);
return cdf_read(info, (off_t)pos, ((char *)buf) + offs, len);
assert((size_t)CDF_SEC_SIZE(h) == len);
return cdf_read(info, (off_t)CDF_SEC_POS(h, id),
((char *)buf) + offs, len);
}
ssize_t
cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
size_t len, const cdf_header_t *h, cdf_secid_t id)
{
size_t ss = CDF_SHORT_SEC_SIZE(h);
size_t pos = CDF_SHORT_SEC_POS(h, id);
assert(ss == len);
if (pos > CDF_SEC_SIZE(h) * sst->sst_len) {
DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
SIZE_T_FORMAT "u\n",
pos, CDF_SEC_SIZE(h) * sst->sst_len));
return -1;
}
assert((size_t)CDF_SHORT_SEC_SIZE(h) == len);
(void)memcpy(((char *)buf) + offs,
((const char *)sst->sst_tab) + pos, len);
((const char *)sst->sst_tab) + CDF_SHORT_SEC_POS(h, id), len);
return len;
}
@@ -392,20 +344,17 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
break;
#define CDF_SEC_LIMIT (UINT32_MAX / (4 * ss))
if ((nsatpersec > 0 &&
h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec) ||
if (h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec ||
i > CDF_SEC_LIMIT) {
DPRINTF(("Number of sectors in master SAT too big %u %"
SIZE_T_FORMAT "u\n", h->h_num_sectors_in_master_sat, i));
DPRINTF(("Number of sectors in master SAT too big %u %zu\n",
h->h_num_sectors_in_master_sat, i));
errno = EFTYPE;
return -1;
}
sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i;
DPRINTF(("sat_len = %" SIZE_T_FORMAT "u ss = %" SIZE_T_FORMAT "u\n",
sat->sat_len, ss));
if ((sat->sat_tab = CAST(cdf_secid_t *, calloc(sat->sat_len, ss)))
== NULL)
DPRINTF(("sat_len = %zu ss = %zu\n", sat->sat_len, ss));
if ((sat->sat_tab = calloc(sat->sat_len, ss)) == NULL)
return -1;
for (i = 0; i < __arraycount(h->h_master_sat); i++) {
@@ -418,7 +367,7 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
}
}
if ((msa = CAST(cdf_secid_t *, calloc(1, ss))) == NULL)
if ((msa = calloc(1, ss)) == NULL)
goto out1;
mid = h->h_secid_first_sector_in_master_sat;
@@ -435,12 +384,12 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
goto out2;
}
for (k = 0; k < nsatpersec; k++, i++) {
sec = CDF_TOLE4((uint32_t)msa[k]);
sec = CDF_TOLE4(msa[k]);
if (sec < 0)
goto out;
if (i >= sat->sat_len) {
DPRINTF(("Out of bounds reading MSA %" SIZE_T_FORMAT
"u >= %" SIZE_T_FORMAT "u", i, sat->sat_len));
DPRINTF(("Out of bounds reading MSA %u >= %u",
i, sat->sat_len));
errno = EFTYPE;
goto out2;
}
@@ -451,7 +400,7 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
goto out2;
}
}
mid = CDF_TOLE4((uint32_t)msa[nsatpersec]);
mid = CDF_TOLE4(msa[nsatpersec]);
}
out:
sat->sat_len = i;
@@ -483,7 +432,7 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
errno = EFTYPE;
return (size_t)-1;
}
sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
sid = CDF_TOLE4(sat->sat_tab[sid]);
}
DPRINTF(("\n"));
return i;
@@ -513,8 +462,7 @@ cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
}
if (i >= scn->sst_len) {
DPRINTF(("Out of bounds reading long sector chain "
"%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
scn->sst_len));
"%u > %u\n", i, scn->sst_len));
errno = EFTYPE;
goto out;
}
@@ -527,7 +475,7 @@ cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
DPRINTF(("Reading long sector chain %d", sid));
goto out;
}
sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
sid = CDF_TOLE4(sat->sat_tab[sid]);
}
return 0;
out:
@@ -559,8 +507,7 @@ cdf_read_short_sector_chain(const cdf_header_t *h,
}
if (i >= scn->sst_len) {
DPRINTF(("Out of bounds reading short sector chain "
"%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n",
i, scn->sst_len));
"%u > %u\n", i, scn->sst_len));
errno = EFTYPE;
goto out;
}
@@ -569,7 +516,7 @@ cdf_read_short_sector_chain(const cdf_header_t *h,
DPRINTF(("Reading short sector chain %d", sid));
goto out;
}
sid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]);
sid = CDF_TOLE4(ssat->sat_tab[sid]);
}
return 0;
out:
@@ -583,7 +530,7 @@ cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
cdf_secid_t sid, size_t len, cdf_stream_t *scn)
{
if (len < h->h_min_size_standard_stream && sst->sst_tab != NULL)
if (len < h->h_min_size_standard_stream)
return cdf_read_short_sector_chain(h, ssat, sst, sid, len,
scn);
else
@@ -606,12 +553,11 @@ cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h,
nd = ss / CDF_DIRECTORY_SIZE;
dir->dir_len = ns * nd;
dir->dir_tab = CAST(cdf_directory_t *,
calloc(dir->dir_len, sizeof(dir->dir_tab[0])));
dir->dir_tab = calloc(dir->dir_len, sizeof(dir->dir_tab[0]));
if (dir->dir_tab == NULL)
return -1;
if ((buf = CAST(char *, malloc(ss))) == NULL) {
if ((buf = malloc(ss)) == NULL) {
free(dir->dir_tab);
return -1;
}
@@ -630,7 +576,7 @@ cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h,
cdf_unpack_dir(&dir->dir_tab[i * nd + j],
&buf[j * CDF_DIRECTORY_SIZE]);
}
sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
sid = CDF_TOLE4(sat->sat_tab[sid]);
}
if (NEED_SWAP)
for (i = 0; i < dir->dir_len; i++)
@@ -656,7 +602,7 @@ cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
if (ssat->sat_len == (size_t)-1)
return -1;
ssat->sat_tab = CAST(cdf_secid_t *, calloc(ssat->sat_len, ss));
ssat->sat_tab = calloc(ssat->sat_len, ss);
if (ssat->sat_tab == NULL)
return -1;
@@ -668,8 +614,7 @@ cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
}
if (i >= ssat->sat_len) {
DPRINTF(("Out of bounds reading short sector chain "
"%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
ssat->sat_len));
"%u > %u\n", i, ssat->sat_len));
errno = EFTYPE;
goto out;
}
@@ -678,7 +623,7 @@ cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
DPRINTF(("Reading short sat sector %d", sid));
goto out;
}
sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
sid = CDF_TOLE4(sat->sat_tab[sid]);
}
return 0;
out:
@@ -706,7 +651,7 @@ cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
if (d->d_stream_first_sector < 0)
goto out;
return cdf_read_long_sector_chain(info, h, sat,
return cdf_read_long_sector_chain(info, h, sat,
d->d_stream_first_sector, d->d_size, scn);
out:
scn->sst_tab = NULL;
@@ -733,45 +678,44 @@ cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
const cdf_directory_t *d;
static const char name[] = "\05SummaryInformation";
for (i = dir->dir_len; i > 0; i--)
if (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&
cdf_namecmp(name, dir->dir_tab[i - 1].d_name, sizeof(name))
for (i = 0; i < dir->dir_len; i++)
if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_USER_STREAM &&
cdf_namecmp(name, dir->dir_tab[i].d_name, sizeof(name))
== 0)
break;
if (i == 0) {
if (i == dir->dir_len) {
DPRINTF(("Cannot find summary information section\n"));
errno = ESRCH;
errno = EFTYPE;
return -1;
}
d = &dir->dir_tab[i - 1];
d = &dir->dir_tab[i];
return cdf_read_sector_chain(info, h, sat, ssat, sst,
d->d_stream_first_sector, d->d_size, scn);
}
int
cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)
cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
cdf_property_info_t **info, size_t *count, size_t *maxcount)
{
const cdf_section_header_t *shp;
cdf_section_header_t sh;
const uint8_t *p, *q, *e;
const uint32_t *p, *q, *e;
int16_t s16;
int32_t s32;
uint32_t u32;
int64_t s64;
uint64_t u64;
cdf_timestamp_t tp;
size_t i, o, o4, nelements, j;
size_t i, o, nelements, j;
cdf_property_info_t *inp;
if (offs > UINT32_MAX / 4) {
errno = EFTYPE;
goto out;
}
shp = CAST(const cdf_section_header_t *, (const void *)
((const char *)sst->sst_tab + offs));
if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1)
shp = (const void *)((const char *)sst->sst_tab + offs);
if (cdf_check_stream_offset(sst, shp, sizeof(*shp)) == -1)
goto out;
sh.sh_len = CDF_TOLE4(shp->sh_len);
#define CDF_SHLEN_LIMIT (UINT32_MAX / 8)
@@ -789,137 +733,105 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
if (*maxcount > CDF_PROP_LIMIT)
goto out;
*maxcount += sh.sh_properties;
inp = CAST(cdf_property_info_t *,
realloc(*info, *maxcount * sizeof(*inp)));
inp = realloc(*info, *maxcount * sizeof(*inp));
} else {
*maxcount = sh.sh_properties;
inp = CAST(cdf_property_info_t *,
malloc(*maxcount * sizeof(*inp)));
inp = malloc(*maxcount * sizeof(*inp));
}
if (inp == NULL)
goto out;
*info = inp;
inp += *count;
*count += sh.sh_properties;
p = CAST(const uint8_t *, (const void *)
((const char *)(const void *)sst->sst_tab +
offs + sizeof(sh)));
e = CAST(const uint8_t *, (const void *)
(((const char *)(const void *)shp) + sh.sh_len));
if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
p = (const void *)((const char *)sst->sst_tab + offs + sizeof(sh));
e = (const void *)(((const char *)shp) + sh.sh_len);
if (cdf_check_stream_offset(sst, e, 0) == -1)
goto out;
for (i = 0; i < sh.sh_properties; i++) {
size_t ofs = CDF_GETUINT32(p, (i << 1) + 1);
q = (const uint8_t *)(const void *)
((const char *)(const void *)p + ofs
- 2 * sizeof(uint32_t));
q = (const uint32_t *)((const char *)p +
CDF_TOLE4(p[(i << 1) + 1])) - 2;
if (q > e) {
DPRINTF(("Ran of the end %p > %p\n", q, e));
goto out;
}
inp[i].pi_id = CDF_GETUINT32(p, i << 1);
inp[i].pi_type = CDF_GETUINT32(q, 0);
DPRINTF(("%" SIZE_T_FORMAT "u) id=%x type=%x offs=0x%tx,0x%x\n",
i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
inp[i].pi_id = CDF_TOLE4(p[i << 1]);
inp[i].pi_type = CDF_TOLE4(q[0]);
DPRINTF(("%d) id=%x type=%x offs=%x\n", i, inp[i].pi_id,
inp[i].pi_type, (const char *)q - (const char *)p));
if (inp[i].pi_type & CDF_VECTOR) {
nelements = CDF_GETUINT32(q, 1);
nelements = CDF_TOLE4(q[1]);
o = 2;
} else {
nelements = 1;
o = 1;
}
o4 = o * sizeof(uint32_t);
if (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED))
goto unknown;
switch (inp[i].pi_type & CDF_TYPEMASK) {
case CDF_NULL:
case CDF_EMPTY:
break;
case CDF_SIGNED16:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&s16, &q[o4], sizeof(s16));
(void)memcpy(&s16, &q[o], sizeof(s16));
inp[i].pi_s16 = CDF_TOLE2(s16);
break;
case CDF_SIGNED32:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&s32, &q[o4], sizeof(s32));
inp[i].pi_s32 = CDF_TOLE4((uint32_t)s32);
(void)memcpy(&s32, &q[o], sizeof(s32));
inp[i].pi_s32 = CDF_TOLE4(s32);
break;
case CDF_BOOL:
case CDF_UNSIGNED32:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&u32, &q[o4], sizeof(u32));
(void)memcpy(&u32, &q[o], sizeof(u32));
inp[i].pi_u32 = CDF_TOLE4(u32);
break;
case CDF_SIGNED64:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&s64, &q[o4], sizeof(s64));
inp[i].pi_s64 = CDF_TOLE8((uint64_t)s64);
(void)memcpy(&s64, &q[o], sizeof(s64));
inp[i].pi_s64 = CDF_TOLE4(s64);
break;
case CDF_UNSIGNED64:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&u64, &q[o4], sizeof(u64));
inp[i].pi_u64 = CDF_TOLE8((uint64_t)u64);
break;
case CDF_FLOAT:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&u32, &q[o4], sizeof(u32));
u32 = CDF_TOLE4(u32);
memcpy(&inp[i].pi_f, &u32, sizeof(inp[i].pi_f));
break;
case CDF_DOUBLE:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&u64, &q[o4], sizeof(u64));
u64 = CDF_TOLE8((uint64_t)u64);
memcpy(&inp[i].pi_d, &u64, sizeof(inp[i].pi_d));
(void)memcpy(&u64, &q[o], sizeof(u64));
inp[i].pi_u64 = CDF_TOLE4(u64);
break;
case CDF_LENGTH32_STRING:
case CDF_LENGTH32_WSTRING:
if (nelements > 1) {
size_t nelem = inp - *info;
if (*maxcount > CDF_PROP_LIMIT
|| nelements > CDF_PROP_LIMIT)
goto out;
*maxcount += nelements;
inp = CAST(cdf_property_info_t *,
realloc(*info, *maxcount * sizeof(*inp)));
inp = realloc(*info, *maxcount * sizeof(*inp));
if (inp == NULL)
goto out;
*info = inp;
inp = *info + nelem;
}
DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
nelements));
DPRINTF(("nelements = %d\n", nelements));
for (j = 0; j < nelements; j++, i++) {
uint32_t l = CDF_GETUINT32(q, o);
uint32_t l = CDF_TOLE4(q[o]);
inp[i].pi_str.s_len = l;
inp[i].pi_str.s_buf = (const char *)
(const void *)(&q[o4 + sizeof(l)]);
DPRINTF(("l = %d, r = %" SIZE_T_FORMAT
"u, s = %s\n", l,
inp[i].pi_str.s_buf = (const char *)(&q[o+1]);
DPRINTF(("l = %d, r = %d, s = %s\n", l,
CDF_ROUND(l, sizeof(l)),
inp[i].pi_str.s_buf));
if (l & 1)
l++;
o += l >> 1;
if (q + o >= e)
goto out;
o4 = o * sizeof(uint32_t);
l = 4 + CDF_ROUND(l, sizeof(l));
o += l >> 2;
}
i--;
break;
case CDF_FILETIME:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&tp, &q[o4], sizeof(tp));
inp[i].pi_tp = CDF_TOLE8((uint64_t)tp);
(void)memcpy(&tp, &q[o], sizeof(tp));
inp[i].pi_tp = CDF_TOLE8(tp);
break;
case CDF_CLIPBOARD:
if (inp[i].pi_type & CDF_VECTOR)
@@ -929,7 +841,7 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
unknown:
DPRINTF(("Don't know how to deal with %x\n",
inp[i].pi_type));
break;
goto out;
}
}
return 0;
@@ -939,18 +851,16 @@ out:
}
int
cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
cdf_unpack_summary_info(const cdf_stream_t *sst, cdf_summary_info_header_t *ssi,
cdf_property_info_t **info, size_t *count)
{
size_t i, maxcount;
const cdf_summary_info_header_t *si =
CAST(const cdf_summary_info_header_t *, sst->sst_tab);
const cdf_section_declaration_t *sd =
CAST(const cdf_section_declaration_t *, (const void *)
((const char *)sst->sst_tab + CDF_SECTION_DECLARATION_OFFSET));
const cdf_summary_info_header_t *si = sst->sst_tab;
const cdf_section_declaration_t *sd = (const void *)
((const char *)sst->sst_tab + CDF_SECTION_DECLARATION_OFFSET);
if (cdf_check_stream_offset(sst, h, si, sizeof(*si), __LINE__) == -1 ||
cdf_check_stream_offset(sst, h, sd, sizeof(*sd), __LINE__) == -1)
if (cdf_check_stream_offset(sst, si, sizeof(*si)) == -1 ||
cdf_check_stream_offset(sst, sd, sizeof(*sd)) == -1)
return -1;
ssi->si_byte_order = CDF_TOLE2(si->si_byte_order);
ssi->si_os_version = CDF_TOLE2(si->si_os_version);
@@ -967,10 +877,9 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
errno = EFTYPE;
return -1;
}
if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset),
info, count, &maxcount) == -1) {
if (cdf_read_property_info(sst, CDF_TOLE4(sd->sd_offset),
info, count, &maxcount) == -1)
return -1;
}
}
return 0;
}
@@ -1027,32 +936,32 @@ cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)
int
cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
{
int len = 0;
size_t len = 0;
int days, hours, mins, secs;
ts /= CDF_TIME_PREC;
secs = (int)(ts % 60);
secs = ts % 60;
ts /= 60;
mins = (int)(ts % 60);
mins = ts % 60;
ts /= 60;
hours = (int)(ts % 24);
hours = ts % 24;
ts /= 24;
days = (int)ts;
days = ts;
if (days) {
len += snprintf(buf + len, bufsiz - len, "%dd+", days);
if ((size_t)len >= bufsiz)
if (len >= bufsiz)
return len;
}
if (days || hours) {
len += snprintf(buf + len, bufsiz - len, "%.2d:", hours);
if ((size_t)len >= bufsiz)
if (len >= bufsiz)
return len;
}
len += snprintf(buf + len, bufsiz - len, "%.2d:", mins);
if ((size_t)len >= bufsiz)
if (len >= bufsiz)
return len;
len += snprintf(buf + len, bufsiz - len, "%.2d", secs);
@@ -1095,14 +1004,13 @@ cdf_dump_sat(const char *prefix, const cdf_sat_t *sat, size_t size)
size_t i, j, s = size / sizeof(cdf_secid_t);
for (i = 0; i < sat->sat_len; i++) {
(void)fprintf(stderr, "%s[%" SIZE_T_FORMAT "u]:\n%.6"
SIZE_T_FORMAT "u: ", prefix, i, i * s);
(void)fprintf(stderr, "%s[%zu]:\n%.6d: ", prefix, i, i * s);
for (j = 0; j < s; j++) {
(void)fprintf(stderr, "%5d, ",
CDF_TOLE4(sat->sat_tab[s * i + j]));
if ((j + 1) % 10 == 0)
(void)fprintf(stderr, "\n%.6" SIZE_T_FORMAT
"u: ", i * s + j + 1);
(void)fprintf(stderr, "\n%.6d: ",
i * s + j + 1);
}
(void)fprintf(stderr, "\n");
}
@@ -1121,8 +1029,7 @@ cdf_dump(void *v, size_t len)
if (j == 16) {
j = 0;
abuf[15] = '\0';
(void)fprintf(stderr, "%s\n%.4" SIZE_T_FORMAT "x: ",
abuf, i + 1);
(void)fprintf(stderr, "%s\n%.4x: ", abuf, i + 1);
}
}
(void)fprintf(stderr, "\n");
@@ -1154,8 +1061,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
d = &dir->dir_tab[i];
for (j = 0; j < sizeof(name); j++)
name[j] = (char)CDF_TOLE2(d->d_name[j]);
(void)fprintf(stderr, "Directory %" SIZE_T_FORMAT "u: %s\n",
i, name);
(void)fprintf(stderr, "Directory %zu: %s\n", i, name);
if (d->d_type < __arraycount(types))
(void)fprintf(stderr, "Type: %s\n", types[d->d_type]);
else
@@ -1166,9 +1072,9 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
(void)fprintf(stderr, "Right child: %d\n", d->d_right_child);
(void)fprintf(stderr, "Flags: 0x%x\n", d->d_flags);
cdf_timestamp_to_timespec(&ts, d->d_created);
(void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec));
(void)fprintf(stderr, "Created %s", ctime(&ts.tv_sec));
cdf_timestamp_to_timespec(&ts, d->d_modified);
(void)fprintf(stderr, "Modified %s", cdf_ctime(&ts.tv_sec));
(void)fprintf(stderr, "Modified %s", ctime(&ts.tv_sec));
(void)fprintf(stderr, "Stream %d\n", d->d_stream_first_sector);
(void)fprintf(stderr, "Size %d\n", d->d_size);
switch (d->d_type) {
@@ -1190,7 +1096,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
default:
break;
}
}
}
@@ -1200,14 +1106,12 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
cdf_timestamp_t tp;
struct timeval ts;
char buf[64];
size_t i, j;
size_t i;
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
(void)fprintf(stderr, "%" SIZE_T_FORMAT "u) %s: ", i, buf);
(void)fprintf(stderr, "%zu) %s: ", i, buf);
switch (info[i].pi_type) {
case CDF_NULL:
break;
case CDF_SIGNED16:
(void)fprintf(stderr, "signed 16 [%hd]\n",
info[i].pi_s16);
@@ -1220,26 +1124,11 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
(void)fprintf(stderr, "unsigned 32 [%u]\n",
info[i].pi_u32);
break;
case CDF_FLOAT:
(void)fprintf(stderr, "float [%g]\n",
info[i].pi_f);
break;
case CDF_DOUBLE:
(void)fprintf(stderr, "double [%g]\n",
info[i].pi_d);
break;
case CDF_LENGTH32_STRING:
(void)fprintf(stderr, "string %u [%.*s]\n",
info[i].pi_str.s_len,
info[i].pi_str.s_len, info[i].pi_str.s_buf);
break;
case CDF_LENGTH32_WSTRING:
(void)fprintf(stderr, "string %u [",
info[i].pi_str.s_len);
for (j = 0; j < info[i].pi_str.s_len - 1; j++)
(void)fputc(info[i].pi_str.s_buf[j << 1], stderr);
(void)fprintf(stderr, "]\n");
break;
case CDF_FILETIME:
tp = info[i].pi_tp;
#if defined(PHP_WIN32) && _MSC_VER <= 1500
@@ -1252,7 +1141,7 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
} else {
cdf_timestamp_to_timespec(&ts, tp);
(void)fprintf(stderr, "timestamp %s",
cdf_ctime(&ts.tv_sec));
ctime(&ts.tv_sec));
}
break;
case CDF_CLIPBOARD:
@@ -1276,7 +1165,7 @@ cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
size_t count;
(void)&h;
if (cdf_unpack_summary_info(sst, h, &ssi, &info, &count) == -1)
if (cdf_unpack_summary_info(sst, &ssi, &info, &count) == -1)
return;
(void)fprintf(stderr, "Endian: %x\n", ssi.si_byte_order);
(void)fprintf(stderr, "Os Version %d.%d\n", ssi.si_os_version & 0xff,
@@ -1328,7 +1217,7 @@ main(int argc, char *argv[])
if (cdf_read_ssat(&info, &h, &sat, &ssat) == -1)
err(1, "Cannot read ssat");
#ifdef CDF_DEBUG
cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
cdf_dump_sat("SSAT", &h, &ssat, CDF_SHORT_SEC_SIZE(&h));
#endif
if (cdf_read_dir(&info, &h, &sat, &dir) == -1)
+22 -42
View File
@@ -24,35 +24,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Parse Composite Document Files, the format used in Microsoft Office
* document files before they switched to zipped XML.
* Info from: http://sc.openoffice.org/compdocfileformat.pdf
*
* N.B. This is the "Composite Document File" format, and not the
* "Compound Document Format", nor the "Channel Definition Format".
* Info from: http://sc.openoffice.org/compdocfileformat.pdf
*/
#ifndef _H_CDF_
#define _H_CDF_
#ifdef PHP_WIN32
#include <winsock2.h>
#define timespec timeval
#define tv_nsec tv_usec
#endif
#ifdef __DJGPP__
#define timespec timeval
#define tv_nsec tv_usec
#endif
typedef int32_t cdf_secid_t;
#define CDF_LOOP_LIMIT 10000
#define CDF_SECID_NULL 0
#define CDF_SECID_FREE -1
#define CDF_SECID_END_OF_CHAIN -2
#define CDF_SECID_SECTOR_ALLOCATION_TABLE -3
#define CDF_SECID_END_OF_CHAIN -2
#define CDF_SECID_SECTOR_ALLOCATION_TABLE -3
#define CDF_SECID_MASTER_SECTOR_ALLOCATION_TABLE -4
typedef struct {
@@ -80,15 +65,15 @@ typedef struct {
cdf_secid_t h_master_sat[436/4];
} cdf_header_t;
#define CDF_SEC_SIZE(h) ((size_t)(1 << (h)->h_sec_size_p2))
#define CDF_SEC_SIZE(h) (1 << (h)->h_sec_size_p2)
#define CDF_SEC_POS(h, secid) (CDF_SEC_SIZE(h) + (secid) * CDF_SEC_SIZE(h))
#define CDF_SHORT_SEC_SIZE(h) ((size_t)(1 << (h)->h_short_sec_size_p2))
#define CDF_SHORT_SEC_SIZE(h) (1 << (h)->h_short_sec_size_p2)
#define CDF_SHORT_SEC_POS(h, secid) ((secid) * CDF_SHORT_SEC_SIZE(h))
typedef int32_t cdf_dirid_t;
typedef int32_t cdf_dirid_t;
#define CDF_DIRID_NULL -1
typedef int64_t cdf_timestamp_t;
typedef int64_t cdf_timestamp_t;
#define CDF_BASE_YEAR 1601
#define CDF_TIME_PREC 10000000
@@ -97,11 +82,11 @@ typedef struct {
uint16_t d_namelen;
uint8_t d_type;
#define CDF_DIR_TYPE_EMPTY 0
#define CDF_DIR_TYPE_USER_STORAGE 1
#define CDF_DIR_TYPE_USER_STREAM 2
#define CDF_DIR_TYPE_LOCKBYTES 3
#define CDF_DIR_TYPE_PROPERTY 4
#define CDF_DIR_TYPE_ROOT_STORAGE 5
#define CDF_DIR_TYPE_USER_STORAGE 1
#define CDF_DIR_TYPE_USER_STREAM 2
#define CDF_DIR_TYPE_LOCKBYTES 3
#define CDF_DIR_TYPE_PROPERTY 4
#define CDF_DIR_TYPE_ROOT_STORAGE 5
uint8_t d_color;
#define CDF_DIR_COLOR_READ 0
#define CDF_DIR_COLOR_BLACK 1
@@ -110,8 +95,8 @@ typedef struct {
cdf_dirid_t d_storage;
uint64_t d_storage_uuid[2];
uint32_t d_flags;
cdf_timestamp_t d_created;
cdf_timestamp_t d_modified;
cdf_timestamp_t d_created;
cdf_timestamp_t d_modified;
cdf_secid_t d_stream_first_sector;
uint32_t d_size;
uint32_t d_unused0;
@@ -173,9 +158,7 @@ typedef struct {
int32_t _pi_s32;
uint64_t _pi_u64;
int64_t _pi_s64;
cdf_timestamp_t _pi_tp;
float _pi_f;
double _pi_d;
cdf_timestamp_t _pi_tp;
struct {
uint32_t s_len;
const char *s_buf;
@@ -187,8 +170,6 @@ typedef struct {
#define pi_s32 pi_val._pi_s32
#define pi_u16 pi_val._pi_u16
#define pi_s16 pi_val._pi_s16
#define pi_f pi_val._pi_f
#define pi_d pi_val._pi_d
#define pi_tp pi_val._pi_tp
#define pi_str pi_val._pi_str
} cdf_property_info_t;
@@ -197,13 +178,13 @@ typedef struct {
/* Variant type definitions */
#define CDF_EMPTY 0x00000000
#define CDF_NULL 0x00000001
#define CDF_NULL 0x00000001
#define CDF_SIGNED16 0x00000002
#define CDF_SIGNED32 0x00000003
#define CDF_FLOAT 0x00000004
#define CDF_DOUBLE 0x00000005
#define CDF_CY 0x00000006
#define CDF_DATE 0x00000007
#define CDF_DATE 0x00000007
#define CDF_BSTR 0x00000008
#define CDF_DISPATCH 0x00000009
#define CDF_ERROR 0x0000000a
@@ -214,7 +195,7 @@ typedef struct {
#define CDF_SIGNED8 0x00000010
#define CDF_UNSIGNED8 0x00000011
#define CDF_UNSIGNED16 0x00000012
#define CDF_UNSIGNED32 0x00000013
#define CDF_UNSIGNED32 0x00000013
#define CDF_SIGNED64 0x00000014
#define CDF_UNSIGNED64 0x00000015
#define CDF_INT 0x00000016
@@ -249,7 +230,7 @@ typedef struct {
#define CDF_PROPERTY_SUBJECT 0x00000003
#define CDF_PROPERTY_AUTHOR 0x00000004
#define CDF_PROPERTY_KEYWORDS 0x00000005
#define CDF_PROPERTY_COMMENTS 0x00000006
#define CDF_PROPERTY_COMMENTS 0x00000006
#define CDF_PROPERTY_TEMPLATE 0x00000007
#define CDF_PROPERTY_LAST_SAVED_BY 0x00000008
#define CDF_PROPERTY_REVISION_NUMBER 0x00000009
@@ -299,20 +280,19 @@ int cdf_read_ssat(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
cdf_sat_t *);
int cdf_read_short_stream(const cdf_info_t *, const cdf_header_t *,
const cdf_sat_t *, const cdf_dir_t *, cdf_stream_t *);
int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
int cdf_read_property_info(const cdf_stream_t *, uint32_t,
cdf_property_info_t **, size_t *, size_t *);
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
const cdf_dir_t *, cdf_stream_t *);
int cdf_unpack_summary_info(const cdf_stream_t *, const cdf_header_t *,
cdf_summary_info_header_t *, cdf_property_info_t **, size_t *);
int cdf_unpack_summary_info(const cdf_stream_t *, cdf_summary_info_header_t *,
cdf_property_info_t **, size_t *);
int cdf_print_classid(char *, size_t, const cdf_classid_t *);
int cdf_print_property_name(char *, size_t, uint32_t);
int cdf_print_elapsed_time(char *, size_t, cdf_timestamp_t);
uint16_t cdf_tole2(uint16_t);
uint32_t cdf_tole4(uint32_t);
uint64_t cdf_tole8(uint64_t);
char *cdf_ctime(const time_t *);
#ifdef CDF_DEBUG
void cdf_dump_header(const cdf_header_t *);
+9 -24
View File
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: cdf_time.c,v 1.11 2011/12/13 13:48:41 christos Exp $")
FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $")
#endif
#include <time.h>
@@ -108,22 +108,22 @@ cdf_timestamp_to_timespec(struct timeval *ts, cdf_timestamp_t t)
ts->tv_usec = (t % CDF_TIME_PREC) * CDF_TIME_PREC;
t /= CDF_TIME_PREC;
tm.tm_sec = (int)(t % 60);
tm.tm_sec = t % 60;
t /= 60;
tm.tm_min = (int)(t % 60);
tm.tm_min = t % 60;
t /= 60;
tm.tm_hour = (int)(t % 24);
tm.tm_hour = t % 24;
t /= 24;
/* XXX: Approx */
tm.tm_year = (int)(CDF_BASE_YEAR + (t / 365));
tm.tm_year = CDF_BASE_YEAR + (t / 365);
rdays = cdf_getdays(tm.tm_year);
t -= rdays - 1;
tm.tm_mday = cdf_getday(tm.tm_year, (int)t);
tm.tm_mon = cdf_getmonth(tm.tm_year, (int)t);
t -= rdays;
tm.tm_mday = cdf_getday(tm.tm_year, t);
tm.tm_mon = cdf_getmonth(tm.tm_year, t);
tm.tm_wday = 0;
tm.tm_yday = 0;
tm.tm_isdst = 0;
@@ -143,13 +143,10 @@ cdf_timestamp_to_timespec(struct timeval *ts, cdf_timestamp_t t)
}
int
/*ARGSUSED*/
cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timeval *ts)
{
#ifndef __lint__
(void)&t;
(void)&ts;
#endif
#ifdef notyet
struct tm tm;
if (gmtime_r(&ts->ts_sec, &tm) == NULL) {
@@ -165,18 +162,6 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timeval *ts)
return 0;
}
char *
cdf_ctime(const time_t *sec)
{
static char ctbuf[26];
char *ptr = ctime(sec);
if (ptr != NULL)
return ptr;
(void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n",
(long long)*sec);
return ctbuf;
}
#ifdef TEST
int
@@ -188,7 +173,7 @@ main(int argc, char *argv[])
char *p, *q;
cdf_timestamp_to_timespec(&ts, tst);
p = cdf_ctime(&ts.tv_sec);
p = ctime(&ts.tv_sec);
if ((q = strchr(p, '\n')) != NULL)
*q = '\0';
if (strcmp(ref, p) != 0)
+16 -21
View File
@@ -36,7 +36,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: compress.c,v 1.68 2011/12/08 12:38:24 rrt Exp $")
FILE_RCSID("@(#)$File: compress.c,v 1.63 2009/03/23 14:21:51 christos Exp $")
#endif
#include "magic.h"
@@ -84,7 +84,6 @@ private const struct {
{ "BZh", 3, { "bzip2", "-cd", NULL }, 1 }, /* bzip2-ed */
{ "LZIP", 4, { "lzip", "-cdq", NULL }, 1 },
{ "\3757zXZ\0",6,{ "xz", "-cd", NULL }, 1 }, /* XZ Utils */
{ "LRZI", 4, { "lrzip", "-dqo-", NULL }, 1 }, /* LRZIP */
};
#define NODATA ((size_t)~0)
@@ -147,13 +146,14 @@ error:
return rv;
}
#endif
/*
* `safe' write for sockets and pipes.
*/
private ssize_t
swrite(int fd, const void *buf, size_t n)
{
ssize_t rv;
int rv;
size_t rn = n;
do
@@ -164,7 +164,7 @@ swrite(int fd, const void *buf, size_t n)
return -1;
default:
n -= rv;
buf = CAST(const char *, buf) + rv;
buf = ((const char *)buf) + rv;
break;
}
while (n > 0);
@@ -178,7 +178,7 @@ swrite(int fd, const void *buf, size_t n)
protected ssize_t
sread(int fd, void *buf, size_t n, int canbepipe)
{
ssize_t rv;
int rv;
#ifdef FIONREAD
int t = 0;
#endif
@@ -224,7 +224,7 @@ sread(int fd, void *buf, size_t n, int canbepipe)
nocheck:
do
switch ((rv = FINFO_READ_FUNC(fd, buf, n))) {
switch ((rv = read(fd, buf, n))) {
case -1:
if (errno == EINTR)
continue;
@@ -245,11 +245,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
size_t nbytes)
{
char buf[4096];
ssize_t r;
int tfd;
#ifdef HAVE_MKSTEMP
int te;
#endif
int r, tfd;
(void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof buf);
#ifndef HAVE_MKSTEMP
@@ -262,9 +258,9 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
}
#else
tfd = mkstemp(buf);
te = errno;
r = errno;
(void)unlink(buf);
errno = te;
errno = r;
#endif
if (tfd == -1) {
file_error(ms, errno,
@@ -301,7 +297,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
return -1;
}
(void)close(tfd);
if (FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
@@ -316,6 +312,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
#define FNAME (1 << 3)
#define FCOMMENT (1 << 4)
private size_t
uncompressgzipped(struct magic_set *ms, const unsigned char *old,
unsigned char **newch, size_t n)
@@ -350,14 +347,13 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
/* XXX: const castaway, via strchr */
z.next_in = (Bytef *)strchr((const char *)old + data_start,
old[data_start]);
z.avail_in = CAST(uint32_t, (n - data_start));
z.avail_in = n - data_start;
z.next_out = *newch;
z.avail_out = HOWMANY;
z.zalloc = Z_NULL;
z.zfree = Z_NULL;
z.opaque = Z_NULL;
/* LINTED bug in header macro */
rc = inflateInit2(&z, -15);
if (rc != Z_OK) {
file_error(ms, 0, "zlib: %s", z.msg);
@@ -385,8 +381,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
const unsigned char *old, unsigned char **newch, size_t n)
{
int fdin[2], fdout[2];
ssize_t r;
pid_t pid;
int r;
#ifdef BUILTIN_DECOMPRESS
/* FIXME: This doesn't cope with bzip2 */
@@ -400,12 +395,12 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
file_error(ms, errno, "cannot create pipe");
return NODATA;
}
switch (pid = fork()) {
switch (fork()) {
case 0: /* child */
(void) close(0);
if (fd != -1) {
(void) dup(fd);
(void) FINFO_LSEEK_FUNC(0, (off_t)0, SEEK_SET);
(void) lseek(0, (off_t)0, SEEK_SET);
} else {
(void) dup(fdin[0]);
(void) close(fdin[0]);
@@ -491,7 +486,7 @@ err:
(void) close(fdin[1]);
(void) close(fdout[0]);
#ifdef WNOHANG
while (waitpid(pid, NULL, WNOHANG) != -1)
while (waitpid(-1, NULL, WNOHANG) != -1)
continue;
#else
(void)wait(NULL);
+2 -2
View File
@@ -35,7 +35,6 @@
switch (type) {
#ifdef ELFCORE
case ET_CORE:
flags |= FLAGS_IS_CORE;
if (dophn_core(ms, clazz, swap, fd,
(off_t)elf_getu(swap, elfhdr.e_phoff),
elf_getu16(swap, elfhdr.e_phnum),
@@ -59,7 +58,8 @@
(off_t)elf_getu(swap, elfhdr.e_shoff),
elf_getu16(swap, elfhdr.e_shnum),
(size_t)elf_getu16(swap, elfhdr.e_shentsize),
fsize, &flags, elf_getu16(swap, elfhdr.e_machine)) == -1)
&flags,
elf_getu16(swap, elfhdr.e_machine)) == -1)
return -1;
break;
+4 -20
View File
@@ -35,7 +35,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: encoding.c,v 1.7 2012/01/24 19:02:02 christos Exp $")
FILE_RCSID("@(#)$File: encoding.c,v 1.3 2009/02/03 20:27:51 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -52,12 +52,6 @@ private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *);
private int looks_extended(const unsigned char *, size_t, unichar *, size_t *);
private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
#ifdef DEBUG_ENCODING
#define DPRINTF(a) printf a
#else
#define DPRINTF(a)
#endif
/*
* Try to determine whether text is in some character code we can
* identify. Each of these tests, if it succeeds, will leave
@@ -71,7 +65,6 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
int rv = 1, ucs_type;
unsigned char *nbuf = NULL;
*type = "text";
mlen = (nbytes + 1) * sizeof(nbuf[0]);
if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) {
file_oomem(ms, mlen);
@@ -83,17 +76,14 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
goto done;
}
*type = "text";
if (looks_ascii(buf, nbytes, *ubuf, ulen)) {
DPRINTF(("ascii %" SIZE_T_FORMAT "u\n", *ulen));
*code = "ASCII";
*code_mime = "us-ascii";
} else if (looks_utf8_with_BOM(buf, nbytes, *ubuf, ulen) > 0) {
DPRINTF(("utf8/bom %" SIZE_T_FORMAT "u\n", *ulen));
*code = "UTF-8 Unicode (with BOM)";
*code_mime = "utf-8";
} else if (file_looks_utf8(buf, nbytes, *ubuf, ulen) > 1) {
DPRINTF(("utf8 %" SIZE_T_FORMAT "u\n", *ulen));
*code = "UTF-8 Unicode (with BOM)";
*code = "UTF-8 Unicode";
*code_mime = "utf-8";
} else if ((ucs_type = looks_ucs16(buf, nbytes, *ubuf, ulen)) != 0) {
@@ -104,36 +94,30 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
*code = "Big-endian UTF-16 Unicode";
*code_mime = "utf-16be";
}
DPRINTF(("ucs16 %" SIZE_T_FORMAT "u\n", *ulen));
} else if (looks_latin1(buf, nbytes, *ubuf, ulen)) {
DPRINTF(("latin1 %" SIZE_T_FORMAT "u\n", *ulen));
*code = "ISO-8859";
*code_mime = "iso-8859-1";
} else if (looks_extended(buf, nbytes, *ubuf, ulen)) {
DPRINTF(("extended %" SIZE_T_FORMAT "u\n", *ulen));
*code = "Non-ISO extended-ASCII";
*code_mime = "unknown-8bit";
} else {
from_ebcdic(buf, nbytes, nbuf);
if (looks_ascii(nbuf, nbytes, *ubuf, ulen)) {
DPRINTF(("ebcdic %" SIZE_T_FORMAT "u\n", *ulen));
*code = "EBCDIC";
*code_mime = "ebcdic";
} else if (looks_latin1(nbuf, nbytes, *ubuf, ulen)) {
DPRINTF(("ebcdic/international %" SIZE_T_FORMAT "u\n",
*ulen));
*code = "International EBCDIC";
*code_mime = "ebcdic";
} else { /* Doesn't look like text at all */
DPRINTF(("binary\n"));
rv = 0;
*type = "binary";
}
}
done:
free(nbuf);
if (nbuf)
free(nbuf);
return rv;
}
+24 -81
View File
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
* @(#)$File: file.h,v 1.135 2011/09/20 15:30:14 christos Exp $
* @(#)$File: file.h,v 1.119 2009/02/04 18:24:32 christos Exp $
*/
#ifndef __file_h__
@@ -35,25 +35,10 @@
#include "config.h"
#ifdef PHP_WIN32
#ifdef _WIN64
#define SIZE_T_FORMAT "I64"
#else
#define SIZE_T_FORMAT ""
#endif
#define INT64_T_FORMAT "I64"
#else
#define SIZE_T_FORMAT "z"
#define INT64_T_FORMAT "ll"
#endif
#include <stdio.h> /* Include that here, to make sure __P gets defined */
#include <errno.h>
#include <fcntl.h> /* For open and flags */
#ifdef HAVE_STDINT_H
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
@@ -95,10 +80,6 @@
#endif
#define public
#ifndef __arraycount
#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
#endif
#ifndef __GNUC_PREREQ__
#ifdef __GNUC__
#define __GNUC_PREREQ__(x, y) \
@@ -123,16 +104,15 @@
#define MAXMAGIS 8192 /* max entries in any one magic file
or directory */
#define MAXDESC 64 /* max leng of text description/MIME type */
#define MAXstring 64 /* max leng of "string" types */
#define MAXstring 32 /* max leng of "string" types */
#define MAGICNO 0xF11E041C
#define VERSIONNO 8
#define FILE_MAGICSIZE 232
#define VERSIONNO 7
#define FILE_MAGICSIZE 200
#define FILE_LOAD 0
#define FILE_CHECK 1
#define FILE_COMPILE 2
#define FILE_LIST 3
union VALUETYPE {
uint8_t b;
@@ -159,7 +139,7 @@ struct magic {
#define NOSPACE 0x10 /* suppress space character before output */
#define BINTEST 0x20 /* test is for a binary type (set only
for top-level tests) */
#define TEXTTEST 0x40 /* for passing to file_softmagic */
#define TEXTTEST 0 /* for passing to file_softmagic */
uint8_t factor;
@@ -285,45 +265,25 @@ struct magic {
#define str_flags _u._s._flags
/* Words 9-16 */
union VALUETYPE value; /* either number or string */
/* Words 17-32 */
/* Words 17-24 */
char desc[MAXDESC]; /* description */
/* Words 33-48 */
/* Words 25-32 */
char mimetype[MAXDESC]; /* MIME type */
/* Words 49-50 */
/* Words 33-34 */
char apple[8];
};
#define BIT(A) (1 << (A))
#define STRING_COMPACT_WHITESPACE BIT(0)
#define STRING_COMPACT_OPTIONAL_WHITESPACE BIT(1)
#define STRING_IGNORE_LOWERCASE BIT(2)
#define STRING_IGNORE_UPPERCASE BIT(3)
#define REGEX_OFFSET_START BIT(4)
#define STRING_TEXTTEST BIT(5)
#define STRING_BINTEST BIT(6)
#define PSTRING_1_BE BIT(7)
#define PSTRING_1_LE BIT(7)
#define PSTRING_2_BE BIT(8)
#define PSTRING_2_LE BIT(9)
#define PSTRING_4_BE BIT(10)
#define PSTRING_4_LE BIT(11)
#define PSTRING_LEN \
(PSTRING_1_BE|PSTRING_2_LE|PSTRING_2_BE|PSTRING_4_LE|PSTRING_4_BE)
#define PSTRING_LENGTH_INCLUDES_ITSELF BIT(12)
#define CHAR_COMPACT_WHITESPACE 'W'
#define CHAR_COMPACT_OPTIONAL_WHITESPACE 'w'
#define CHAR_IGNORE_LOWERCASE 'c'
#define CHAR_IGNORE_UPPERCASE 'C'
#define CHAR_REGEX_OFFSET_START 's'
#define CHAR_TEXTTEST 't'
#define CHAR_BINTEST 'b'
#define CHAR_PSTRING_1_BE 'B'
#define CHAR_PSTRING_1_LE 'B'
#define CHAR_PSTRING_2_BE 'H'
#define CHAR_PSTRING_2_LE 'h'
#define CHAR_PSTRING_4_BE 'L'
#define CHAR_PSTRING_4_LE 'l'
#define CHAR_PSTRING_LENGTH_INCLUDES_ITSELF 'J'
#define STRING_COMPACT_BLANK BIT(0)
#define STRING_COMPACT_OPTIONAL_BLANK BIT(1)
#define STRING_IGNORE_LOWERCASE BIT(2)
#define STRING_IGNORE_UPPERCASE BIT(3)
#define REGEX_OFFSET_START BIT(4)
#define CHAR_COMPACT_BLANK 'B'
#define CHAR_COMPACT_OPTIONAL_BLANK 'b'
#define CHAR_IGNORE_LOWERCASE 'c'
#define CHAR_IGNORE_UPPERCASE 'C'
#define CHAR_REGEX_OFFSET_START 's'
#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE)
#define STRING_DEFAULT_RANGE 100
@@ -340,10 +300,8 @@ struct mlist {
#ifdef __cplusplus
#define CAST(T, b) static_cast<T>(b)
#define RCAST(T, b) reinterpret_cast<T>(b)
#else
#define CAST(T, b) (T)(b)
#define RCAST(T, b) (T)(b)
#define CAST(T, b) (b)
#endif
struct level_info {
@@ -394,7 +352,6 @@ protected int file_buffer(struct magic_set *, php_stream *, const char *, const
size_t);
protected int file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *stream);
protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
protected int file_replace(struct magic_set *, const char *, const char *);
protected int file_printf(struct magic_set *, const char *, ...);
protected int file_reset(struct magic_set *);
protected int file_tryelf(struct magic_set *, int, const unsigned char *,
@@ -405,16 +362,15 @@ protected int file_trycdf(struct magic_set *, int, const unsigned char *,
protected int file_zmagic(struct magic_set *, int, const char *,
const unsigned char *, size_t);
#endif
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t,
int);
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_ascmagic_with_encoding(struct magic_set *,
const unsigned char *, size_t, unichar *, size_t, const char *,
const char *, int);
const char *);
protected int file_encoding(struct magic_set *, const unsigned char *, size_t,
unichar **, size_t *, const char **, const char **, const char **);
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
protected int file_softmagic(struct magic_set *, const unsigned char *, size_t,
int, int);
int);
protected struct mlist *file_apprentice(struct magic_set *, const char *, int);
protected uint64_t file_signextend(struct magic_set *, struct magic *,
uint64_t);
@@ -432,8 +388,6 @@ protected ssize_t sread(int, void *, size_t, int);
protected int file_check_mem(struct magic_set *, unsigned int);
protected int file_looks_utf8(const unsigned char *, size_t, unichar *,
size_t *);
protected size_t file_pstring_length_size(const struct magic *);
protected size_t file_pstring_get_length(const struct magic *, const char *);
#ifdef __EMX__
protected int file_os2_apptype(struct magic_set *, const char *, const void *,
size_t);
@@ -459,10 +413,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
#ifndef strlcat
size_t strlcat(char *dst, const char *src, size_t siz);
#endif
#ifndef HAVE_GETLINE
ssize_t getline(char **dst, size_t *len, FILE *fp);
ssize_t getdelim(char **dst, size_t *len, int delimiter, FILE *fp);
#endif
#if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
#define QUICK
@@ -473,7 +424,7 @@ ssize_t getdelim(char **dst, size_t *len, int delimiter, FILE *fp);
#endif
#ifndef __cplusplus
#if defined(__GNUC__) && (__GNUC__ >= 3)
#ifdef __GNUC__
#define FILE_RCSID(id) \
static const char rcsid[] __attribute__((__used__)) = id;
#else
@@ -486,12 +437,4 @@ static const char *rcsid(const char *p) { \
#define FILE_RCSID(id)
#endif
#ifdef PHP_WIN32
#define FINFO_LSEEK_FUNC _lseek
#define FINFO_READ_FUNC _read
#else
#define FINFO_LSEEK_FUNC lseek
#define FINFO_READ_FUNC read
#endif
#endif /* __file_h__ */
+21 -20
View File
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: fsmagic.c,v 1.64 2011/08/14 09:03:12 christos Exp $")
FILE_RCSID("@(#)$File: fsmagic.c,v 1.59 2009/02/03 20:27:51 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -78,7 +78,7 @@ private int
handle_mime(struct magic_set *ms, int mime, const char *str)
{
if ((mime & MAGIC_MIME_TYPE)) {
if (file_printf(ms, "inode/%s", str) == -1)
if (file_printf(ms, "application/%s", str) == -1)
return -1;
if ((mime & MAGIC_MIME_ENCODING) && file_printf(ms,
"; charset=") == -1)
@@ -139,7 +139,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *
return -1;
#endif
}
switch (sb->st_mode & S_IFMT) {
#ifndef PHP_WIN32
# ifdef S_IFCHR
@@ -178,25 +178,26 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *
#endif
#ifdef S_IFIFO
case S_IFIFO:
if((ms->flags & MAGIC_DEVICES) != 0)
break;
if (mime) {
if (handle_mime(ms, mime, "fifo") == -1)
return -1;
} else if (file_printf(ms, "fifo (named pipe)") == -1)
return -1;
return 1;
case S_IFIFO:
if((ms->flags & MAGIC_DEVICES) != 0)
break;
if (mime) {
if (handle_mime(ms, mime, "x-fifo") == -1)
return -1;
} else if (file_printf(ms, "fifo (named pipe)") == -1)
return -1;
return 1;
#endif
#ifdef S_IFDOOR
case S_IFDOOR:
if (mime) {
if (handle_mime(ms, mime, "door") == -1)
return -1;
} else if (file_printf(ms, "door") == -1)
return -1;
return 1;
case S_IFDOOR:
if (mime) {
if (handle_mime(ms, mime, "x-door") == -1)
return -1;
} else if (file_printf(ms, "door") == -1)
return -1;
return 1;
#endif
#ifdef S_IFLNK
case S_IFLNK:
/* stat is used, if it made here then the link is broken */
@@ -211,7 +212,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb, php_stream *
#ifndef __COHERENT__
case S_IFSOCK:
if (mime) {
if (handle_mime(ms, mime, "socket") == -1)
if (handle_mime(ms, mime, "x-socket") == -1)
return -1;
} else if (file_printf(ms, "socket") == -1)
return -1;
+18 -78
View File
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: funcs.c,v 1.60 2011/12/08 12:38:24 rrt Exp $")
FILE_RCSID("@(#)$File: funcs.c,v 1.53 2009/04/07 11:07:00 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -46,12 +46,6 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.60 2011/12/08 12:38:24 rrt Exp $")
# define SIZE_MAX ((size_t) -1)
#endif
#ifndef PREG_OFFSET_CAPTURE
# define PREG_OFFSET_CAPTURE (1<<8)
#endif
extern public void convert_libmagic_pattern(zval *pattern, int options);
/*
* Like printf, only we append to a buffer.
*/
@@ -85,17 +79,19 @@ file_printf(struct magic_set *ms, const char *fmt, ...)
/*VARARGS*/
private void
file_error_core(struct magic_set *ms, int error, const char *f, va_list va,
size_t lineno)
uint32_t lineno)
{
char *buf = NULL;
/* Only the first error is ok */
if (ms->event_flags & EVENT_HAD_ERR)
if (ms->event_flags & EVENT_HAD_ERR) {
return;
}
if (lineno != 0) {
efree(ms->o.buf);
ms->o.buf = NULL;
file_printf(ms, "line %" SIZE_T_FORMAT "u: ", lineno);
file_printf(ms, "line %u: ", lineno);
}
vspprintf(&buf, 0, f, va);
@@ -141,8 +137,7 @@ file_magerror(struct magic_set *ms, const char *f, ...)
protected void
file_oomem(struct magic_set *ms, size_t len)
{
file_error(ms, errno, "cannot allocate %" SIZE_T_FORMAT "u bytes",
len);
file_error(ms, errno, "cannot allocate %zu bytes", len);
}
protected void
@@ -163,7 +158,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
{
int m = 0, rv = 0, looks_text = 0;
int mime = ms->flags & MAGIC_MIME;
const unsigned char *ubuf = CAST(const unsigned char *, buf);
const unsigned char *ubuf = buf;
unichar *u8buf = NULL;
size_t ulen;
const char *code = NULL;
@@ -210,8 +205,9 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "zmagic %d\n", m);
goto done;
}
}
#endif
/* Check if we have a tar file */
if ((ms->flags & MAGIC_NO_CHECK_TAR) == 0)
if ((m = file_is_tar(ms, ubuf, nb)) != 0) {
@@ -235,8 +231,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
/* try soft magic tests */
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
if ((m = file_softmagic(ms, ubuf, nb, BINTEST,
looks_text)) != 0) {
if ((m = file_softmagic(ms, ubuf, nb, BINTEST)) != 0) {
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "softmagic %d\n", m);
#ifdef BUILTIN_ELF
@@ -260,10 +255,10 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
goto done;
}
/* try text properties */
/* try text properties (and possibly text tokens) */
if ((ms->flags & MAGIC_NO_CHECK_TEXT) == 0) {
if ((m = file_ascmagic(ms, ubuf, nb, looks_text)) != 0) {
if ((m = file_ascmagic(ms, ubuf, nb)) != 0) {
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr, "ascmagic %d\n", m);
goto done;
@@ -273,8 +268,7 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
if ((ms->flags & MAGIC_NO_CHECK_ENCODING) == 0) {
if (looks_text == 0)
if ((m = file_ascmagic_with_encoding( ms, ubuf,
nb, u8buf, ulen, code, type, looks_text))
!= 0) {
nb, u8buf, ulen, code, type)) != 0) {
if ((ms->flags & MAGIC_DEBUG) != 0)
(void)fprintf(stderr,
"ascmagic/enc %d\n", m);
@@ -297,7 +291,8 @@ file_buffer(struct magic_set *ms, php_stream *stream, const char *inname, const
if (file_printf(ms, "%s", code_mime) == -1)
rv = -1;
}
free(u8buf);
if (u8buf)
free(u8buf);
if (rv)
return rv;
@@ -395,9 +390,9 @@ file_getbuffer(struct magic_set *ms)
}
#endif
for (np = ms->o.pbuf, op = ms->o.buf; *op;) {
for (np = ms->o.pbuf, op = ms->o.buf; *op; op++) {
if (isprint((unsigned char)*op)) {
*np++ = *op++;
*np++ = *op;
} else {
OCTALIFY(np, op);
}
@@ -422,58 +417,3 @@ file_check_mem(struct magic_set *ms, unsigned int level)
#endif /* ENABLE_CONDITIONALS */
return 0;
}
protected size_t
file_printedlen(const struct magic_set *ms)
{
return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
}
protected int
file_replace(struct magic_set *ms, const char *pat, const char *rep)
{
zval *patt;
int opts = 0;
pcre_cache_entry *pce;
char *res;
zval *repl;
int res_len, rep_cnt;
TSRMLS_FETCH();
MAKE_STD_ZVAL(patt);
ZVAL_STRINGL(patt, pat, strlen(pat), 0);
opts |= PCRE_MULTILINE;
convert_libmagic_pattern(patt, opts);
#if (PHP_MAJOR_VERSION < 6)
if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(patt), Z_STRLEN_P(patt) TSRMLS_CC)) == NULL) {
#else
if ((pce = pcre_get_compiled_regex_cache(IS_STRING, Z_STRVAL_P(patt), Z_STRLEN_P(patt) TSRMLS_CC)) == NULL) {
#endif
zval_dtor(patt);
FREE_ZVAL(patt);
return -1;
}
MAKE_STD_ZVAL(repl);
ZVAL_STRINGL(repl, rep, strlen(rep), 0);
res = php_pcre_replace_impl(pce, ms->o.buf, strlen(ms->o.buf), repl,
0, &res_len, -1, &rep_cnt TSRMLS_CC);
FREE_ZVAL(repl);
zval_dtor(patt);
FREE_ZVAL(patt);
if (NULL == res) {
return -1;
}
strncpy(ms->o.buf, res, res_len);
ms->o.buf[res_len] = '\0';
efree(res);
return rep_cnt;
}
+21 -16
View File
@@ -2,7 +2,7 @@
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,7 +40,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: is_tar.c,v 1.37 2010/11/30 14:58:53 rrt Exp $")
FILE_RCSID("@(#)$File: is_tar.c,v 1.36 2009/02/03 20:27:51 christos Exp $")
#endif
#include "magic.h"
@@ -83,8 +83,8 @@ file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
}
/*
* Return
* 0 if the checksum is bad (i.e., probably not a tar archive),
* Return
* 0 if the checksum is bad (i.e., probably not a tar archive),
* 1 for old UNIX tar file,
* 2 for Unix Std (POSIX) tar file,
* 3 for GNU tar file.
@@ -95,7 +95,7 @@ is_tar(const unsigned char *buf, size_t nbytes)
const union record *header = (const union record *)(const void *)buf;
int i;
int sum, recsum;
const unsigned char *p;
const char *p;
if (nbytes < sizeof(union record))
return 0;
@@ -104,20 +104,25 @@ is_tar(const unsigned char *buf, size_t nbytes)
sum = 0;
p = header->charptr;
for (i = sizeof(union record); --i >= 0;)
sum += *p++;
for (i = sizeof(union record); --i >= 0;) {
/*
* We cannot use unsigned char here because of old compilers,
* e.g. V7.
*/
sum += 0xFF & *p++;
}
/* Adjust checksum to count the "chksum" field as blanks. */
for (i = sizeof(header->header.chksum); --i >= 0;)
sum -= header->header.chksum[i];
sum += ' ' * sizeof header->header.chksum;
sum -= 0xFF & header->header.chksum[i];
sum += ' '* sizeof header->header.chksum;
if (sum != recsum)
return 0; /* Not a tar archive */
if (strcmp(header->header.magic, GNUTMAGIC) == 0)
if (strcmp(header->header.magic, GNUTMAGIC) == 0)
return 3; /* GNU Unix Standard tar archive */
if (strcmp(header->header.magic, TMAGIC) == 0)
if (strcmp(header->header.magic, TMAGIC) == 0)
return 2; /* Unix Standard tar archive */
return 1; /* Old fashioned tar archive */
@@ -127,7 +132,7 @@ is_tar(const unsigned char *buf, size_t nbytes)
/*
* Quick and dirty octal conversion.
*
* Result is -1 if the field is invalid (all blank, or non-octal).
* Result is -1 if the field is invalid (all blank, or nonoctal).
*/
private int
from_oct(int digs, const char *where)
@@ -140,13 +145,13 @@ from_oct(int digs, const char *where)
return -1; /* All blank field */
}
value = 0;
while (digs > 0 && isodigit(*where)) { /* Scan til non-octal */
while (digs > 0 && isodigit(*where)) { /* Scan til nonoctal */
value = (value << 3) | (*where++ - '0');
--digs;
}
if (digs > 0 && *where && !isspace((unsigned char)*where))
return -1; /* Ended on non-(space/NUL) */
return -1; /* Ended on non-space/nul */
return value;
}
+16 -151
View File
@@ -28,7 +28,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: magic.c,v 1.74 2011/05/26 01:27:59 christos Exp $")
FILE_RCSID("@(#)$File: magic.c,v 1.62 2009/03/20 21:25:41 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -46,10 +46,6 @@ FILE_RCSID("@(#)$File: magic.c,v 1.74 2011/05/26 01:27:59 christos Exp $")
# include "php_config.h"
#endif
#ifdef PHP_WIN32
#include <shlwapi.h>
#endif
#include <limits.h> /* for PIPE_BUF */
#if defined(HAVE_UTIMES)
@@ -66,6 +62,12 @@ FILE_RCSID("@(#)$File: magic.c,v 1.74 2011/05/26 01:27:59 christos Exp $")
#include <unistd.h> /* for read() */
#endif
#ifndef PHP_WIN32
# include <netinet/in.h> /* for byte swapping */
#endif
#include "patchlevel.h"
#ifndef PIPE_BUF
/* Get the PIPE_BUF from pathconf */
#ifdef _PC_PIPE_BUF
@@ -84,140 +86,12 @@ private void free_mlist(struct mlist *);
private void close_and_restore(const struct magic_set *, const char *, int,
const struct stat *);
private int unreadable_info(struct magic_set *, mode_t, const char *);
private const char* get_default_magic(void);
private const char *file_or_stream(struct magic_set *, const char *, php_stream *);
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
/* XXX this functionality is excluded in php, enable it in apprentice.c:340 */
#if 0
private const char *
get_default_magic(void)
{
static const char hmagic[] = "/.magic/magic.mgc";
static char *default_magic;
char *home, *hmagicpath;
#ifndef PHP_WIN32
struct stat st;
if (default_magic) {
free(default_magic);
default_magic = NULL;
}
if ((home = getenv("HOME")) == NULL)
return MAGIC;
if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
return MAGIC;
if (stat(hmagicpath, &st) == -1)
goto out;
if (S_ISDIR(st.st_mode)) {
free(hmagicpath);
if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
return MAGIC;
if (access(hmagicpath, R_OK) == -1)
goto out;
}
if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)
goto out;
free(hmagicpath);
return default_magic;
out:
default_magic = NULL;
free(hmagicpath);
return MAGIC;
#else
char *hmagicp = hmagicpath;
char *tmppath = NULL;
LPTSTR dllpath;
#define APPENDPATH() \
do { \
if (tmppath && access(tmppath, R_OK) != -1) { \
if (hmagicpath == NULL) \
hmagicpath = tmppath; \
else { \
if (asprintf(&hmagicp, "%s%c%s", hmagicpath, \
PATHSEP, tmppath) >= 0) { \
free(hmagicpath); \
hmagicpath = hmagicp; \
} \
free(tmppath); \
} \
tmppath = NULL; \
} \
} while (/*CONSTCOND*/0)
if (default_magic) {
free(default_magic);
default_magic = NULL;
}
/* First, try to get user-specific magic file */
if ((home = getenv("LOCALAPPDATA")) == NULL) {
if ((home = getenv("USERPROFILE")) != NULL)
if (asprintf(&tmppath,
"%s/Local Settings/Application Data%s", home,
hmagic) < 0)
tmppath = NULL;
} else {
if (asprintf(&tmppath, "%s%s", home, hmagic) < 0)
tmppath = NULL;
}
APPENDPATH();
/* Second, try to get a magic file from Common Files */
if ((home = getenv("COMMONPROGRAMFILES")) != NULL) {
if (asprintf(&tmppath, "%s%s", home, hmagic) >= 0)
APPENDPATH();
}
/* Third, try to get magic file relative to dll location */
dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1));
dllpath[MAX_PATH] = 0; /* just in case long path gets truncated and not null terminated */
if (GetModuleFileNameA(NULL, dllpath, MAX_PATH)){
PathRemoveFileSpecA(dllpath);
if (strlen(dllpath) > 3 &&
stricmp(&dllpath[strlen(dllpath) - 3], "bin") == 0) {
if (asprintf(&tmppath,
"%s/../share/misc/magic.mgc", dllpath) >= 0)
APPENDPATH();
} else {
if (asprintf(&tmppath,
"%s/share/misc/magic.mgc", dllpath) >= 0)
APPENDPATH();
else if (asprintf(&tmppath,
"%s/magic.mgc", dllpath) >= 0)
APPENDPATH();
}
}
/* Don't put MAGIC constant - it likely points to a file within MSys
tree */
default_magic = hmagicpath;
return default_magic;
#endif
}
public const char *
magic_getpath(const char *magicfile, int action)
{
if (magicfile != NULL)
return magicfile;
magicfile = getenv("MAGIC");
if (magicfile != NULL)
return magicfile;
return action == FILE_LOAD ? get_default_magic() : MAGIC;
}
#endif
public struct magic_set *
magic_open(int flags)
{
@@ -322,15 +196,6 @@ magic_compile(struct magic_set *ms, const char *magicfile)
return ml ? 0 : -1;
}
public int
magic_list(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml = file_apprentice(ms, magicfile, FILE_LIST);
free_mlist(ml);
return ml ? 0 : -1;
}
private void
close_and_restore(const struct magic_set *ms, const char *name, int fd,
const struct stat *sb)
@@ -407,17 +272,18 @@ file_or_stream(struct magic_set *ms, const char *inname, php_stream *stream)
#define SLOP (1 + sizeof(union VALUETYPE))
buf = emalloc(HOWMANY + SLOP);
if (file_reset(ms) == -1)
if (file_reset(ms) == -1) {
goto done;
}
switch (file_fsmagic(ms, inname, &sb, stream)) {
case -1: /* error */
goto done;
case 0: /* nothing found */
break;
default: /* matched it and printed type */
rv = 0;
goto done;
case -1: /* error */
goto done;
case 0: /* nothing found */
break;
default: /* matched it and printed type */
rv = 0;
goto done;
}
errno = 0;
@@ -465,7 +331,6 @@ done:
return rv == 0 ? file_getbuffer(ms) : NULL;
}
public const char *
magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
{
-16
View File
@@ -43,7 +43,6 @@
#define MAGIC_MIME_ENCODING 0x000400 /* Return the MIME encoding */
#define MAGIC_MIME (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)
#define MAGIC_APPLE 0x000800 /* Return the Apple creator and type */
#define MAGIC_NO_CHECK_COMPRESS 0x001000 /* Don't check for compressed files */
#define MAGIC_NO_CHECK_TAR 0x002000 /* Don't check for tar files */
#define MAGIC_NO_CHECK_SOFT 0x004000 /* Don't check magic entries */
@@ -54,19 +53,6 @@
#define MAGIC_NO_CHECK_TOKENS 0x100000 /* Don't check tokens */
#define MAGIC_NO_CHECK_ENCODING 0x200000 /* Don't check text encodings */
/* No built-in tests; only consult the magic file */
#define MAGIC_NO_CHECK_BUILTIN ( \
MAGIC_NO_CHECK_COMPRESS | \
MAGIC_NO_CHECK_TAR | \
/* MAGIC_NO_CHECK_SOFT | */ \
MAGIC_NO_CHECK_APPTYPE | \
MAGIC_NO_CHECK_ELF | \
MAGIC_NO_CHECK_TEXT | \
MAGIC_NO_CHECK_CDF | \
MAGIC_NO_CHECK_TOKENS | \
MAGIC_NO_CHECK_ENCODING | \
)
/* Defined for backwards compatibility (renamed) */
#define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT
@@ -83,7 +69,6 @@ typedef struct magic_set *magic_t;
magic_t magic_open(int);
void magic_close(magic_t);
const char *magic_getpath(const char *, int);
const char *magic_file(magic_t, const char *);
const char *magic_stream(magic_t, php_stream *);
const char *magic_descriptor(magic_t, int);
@@ -94,7 +79,6 @@ int magic_setflags(magic_t, int);
int magic_load(magic_t, const char *);
int magic_compile(magic_t, const char *);
int magic_list(magic_t, const char *);
int magic_errno(magic_t);
#ifdef __cplusplus
+1 -7
View File
@@ -1,17 +1,11 @@
#define FILE_VERSION_MAJOR 5
#define patchlevel 11
#define patchlevel 3
/*
* Patchlevel file for Ian Darwin's MAGIC command.
* $File: patchlevel.h,v 1.68 2008/03/22 21:39:43 christos Exp $
*
* $Log$
* Revision 1.6 2012/03/26 21:01:37 ab
* Update libmagic to 5.11
*
* Revision 1.5 2012/03/25 13:54:37 ab
* Update libmagic to 5.04
*
* Revision 1.4 2009/05/04 20:52:43 scottmac
* Update libmagic to 5.02
*
+3 -7
View File
@@ -35,7 +35,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: print.c,v 1.71 2011/09/20 15:28:09 christos Exp $")
FILE_RCSID("@(#)$File: print.c,v 1.66 2009/02/03 20:27:51 christos Exp $")
#endif /* lint */
#include <string.h>
@@ -85,7 +85,7 @@ file_fmttime(uint32_t v, int local)
(void)time(&now);
tm1 = localtime(&now);
if (tm1 == NULL)
goto out;
return "*Invalid time*";
daylight = tm1->tm_isdst;
}
#endif /* HAVE_TM_ISDST */
@@ -94,14 +94,10 @@ file_fmttime(uint32_t v, int local)
t += 3600;
tm = gmtime(&t);
if (tm == NULL)
goto out;
return "*Invalid time*";
pp = asctime(tm);
}
if (pp == NULL)
goto out;
pp[strcspn(pp, "\n")] = '\0';
return pp;
out:
return "*Invalid time*";
}
+192 -240
View File
@@ -26,7 +26,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: readcdf.c,v 1.29 2012/02/20 20:04:58 christos Exp $")
FILE_RCSID("@(#)$File: readcdf.c,v 1.18 2009/05/06 20:48:22 christos Exp $")
#endif
#include <stdlib.h>
@@ -48,281 +48,233 @@ private int
cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
size_t count)
{
size_t i;
cdf_timestamp_t tp;
struct timeval ts;
char buf[64];
const char *str = NULL;
const char *s;
int len;
size_t i;
cdf_timestamp_t tp;
struct timeval ts;
char buf[64];
const char *str = "vnd.ms-office";
const char *s;
int len;
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
switch (info[i].pi_type) {
case CDF_NULL:
break;
case CDF_SIGNED16:
if (NOTMIME(ms) && file_printf(ms, ", %s: %hd", buf,
info[i].pi_s16) == -1)
return -1;
break;
case CDF_SIGNED32:
if (NOTMIME(ms) && file_printf(ms, ", %s: %d", buf,
info[i].pi_s32) == -1)
return -1;
break;
case CDF_UNSIGNED32:
if (NOTMIME(ms) && file_printf(ms, ", %s: %u", buf,
info[i].pi_u32) == -1)
return -1;
break;
case CDF_FLOAT:
if (NOTMIME(ms) && file_printf(ms, ", %s: %g", buf,
info[i].pi_f) == -1)
return -1;
break;
case CDF_DOUBLE:
if (NOTMIME(ms) && file_printf(ms, ", %s: %g", buf,
info[i].pi_d) == -1)
return -1;
break;
case CDF_LENGTH32_STRING:
case CDF_LENGTH32_WSTRING:
len = info[i].pi_str.s_len;
if (len > 1) {
char vbuf[1024];
size_t j, k = 1;
if (info[i].pi_type == CDF_LENGTH32_WSTRING)
k++;
s = info[i].pi_str.s_buf;
for (j = 0; j < sizeof(vbuf) && len--;
j++, s += k) {
if (*s == '\0')
break;
if (isprint((unsigned char)*s))
vbuf[j] = *s;
}
if (j == sizeof(vbuf))
--j;
vbuf[j] = '\0';
if (NOTMIME(ms)) {
if (vbuf[0]) {
if (file_printf(ms, ", %s: %s",
buf, vbuf) == -1)
return -1;
}
} else if (info[i].pi_id ==
CDF_PROPERTY_NAME_OF_APPLICATION) {
if (strstr(vbuf, "Word"))
str = "msword";
else if (strstr(vbuf, "Excel"))
str = "vnd.ms-excel";
else if (strstr(vbuf, "Powerpoint"))
str = "vnd.ms-powerpoint";
else if (strstr(vbuf,
"Crystal Reports"))
str = "x-rpt";
}
}
break;
case CDF_FILETIME:
tp = info[i].pi_tp;
if (tp != 0) {
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
switch (info[i].pi_type) {
case CDF_SIGNED16:
if (NOTMIME(ms) && file_printf(ms, ", %s: %hd", buf,
info[i].pi_s16) == -1)
return -1;
break;
case CDF_SIGNED32:
if (NOTMIME(ms) && file_printf(ms, ", %s: %d", buf,
info[i].pi_s32) == -1)
return -1;
break;
case CDF_UNSIGNED32:
if (NOTMIME(ms) && file_printf(ms, ", %s: %u", buf,
info[i].pi_u32) == -1)
return -1;
break;
case CDF_LENGTH32_STRING:
len = info[i].pi_str.s_len;
if (len > 1) {
s = info[i].pi_str.s_buf;
if (NOTMIME(ms)) {
char vbuf[1024];
size_t j;
for (j = 0; j < sizeof(vbuf) && len--;
j++, s++) {
if (*s == '\0')
break;
if (isprint((unsigned char)*s))
vbuf[j] = *s;
}
if (j == sizeof(vbuf))
--j;
vbuf[j] = '\0';
if (vbuf[0]) {
if (file_printf(ms, ", %s: %s",
buf, vbuf) == -1)
return -1;
}
} else if (info[i].pi_id ==
CDF_PROPERTY_NAME_OF_APPLICATION) {
if (strstr(s, "Word"))
str = "msword";
else if (strstr(s, "Excel"))
str = "vnd.ms-excel";
else if (strstr(s, "Powerpoint"))
str = "vnd.ms-powerpoint";
}
}
break;
case CDF_FILETIME:
tp = info[i].pi_tp;
if (tp != 0) {
#if defined(PHP_WIN32) && _MSC_VER <= 1500
if (tp < 1000000000000000i64) {
if (tp < 1000000000000000i64) {
#else
if (tp < 1000000000000000LL) {
if (tp < 1000000000000000LL) {
#endif
char tbuf[64];
cdf_print_elapsed_time(tbuf,
sizeof(tbuf), tp);
if (NOTMIME(ms) && file_printf(ms,
", %s: %s", buf, tbuf) == -1)
return -1;
} else {
char *c, *ec;
if (cdf_timestamp_to_timespec(&ts, tp) == -1) {
return -1;
}
c = cdf_ctime(&ts.tv_sec);
if ((ec = strchr(c, '\n')) != NULL)
*ec = '\0';
char tbuf[64];
cdf_print_elapsed_time(tbuf,
sizeof(tbuf), tp);
if (NOTMIME(ms) && file_printf(ms,
", %s: %s", buf, tbuf) == -1)
return -1;
} else {
char *c, *ec;
if (NOTMIME(ms) && file_printf(ms,
", %s: %s", buf, c) == -1)
return -1;
}
}
break;
case CDF_CLIPBOARD:
break;
default:
return -1;
}
}
if (!NOTMIME(ms)) {
if (str == NULL)
return 0;
if (file_printf(ms, "application/%s", str) == -1)
return -1;
}
return 1;
if (cdf_timestamp_to_timespec(&ts, tp) == -1) {
return -1;
}
c = ctime(&ts.tv_sec);
if ((ec = strchr(c, '\n')) != NULL)
*ec = '\0';
if (NOTMIME(ms) && file_printf(ms,
", %s: %s", buf, c) == -1)
return -1;
}
}
break;
case CDF_CLIPBOARD:
break;
default:
return -1;
}
}
if (!NOTMIME(ms)) {
if (file_printf(ms, "application/%s", str) == -1)
return -1;
}
return 1;
}
private int
cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
const cdf_stream_t *sst)
cdf_file_summary_info(struct magic_set *ms, const cdf_stream_t *sst)
{
cdf_summary_info_header_t si;
cdf_property_info_t *info;
size_t count;
int m;
cdf_summary_info_header_t si;
cdf_property_info_t *info;
size_t count;
int m;
if (cdf_unpack_summary_info(sst, h, &si, &info, &count) == -1)
return -1;
if (cdf_unpack_summary_info(sst, &si, &info, &count) == -1)
return -1;
if (NOTMIME(ms)) {
if (file_printf(ms, "Composite Document File V2 Document")
== -1)
return -1;
if (NOTMIME(ms)) {
if (file_printf(ms, "CDF V2 Document") == -1)
return -1;
if (file_printf(ms, ", %s Endian",
si.si_byte_order == 0xfffe ? "Little" : "Big") == -1)
return -2;
switch (si.si_os) {
case 2:
if (file_printf(ms, ", Os: Windows, Version %d.%d",
si.si_os_version & 0xff,
(uint32_t)si.si_os_version >> 8) == -1)
return -2;
break;
case 1:
if (file_printf(ms, ", Os: MacOS, Version %d.%d",
(uint32_t)si.si_os_version >> 8,
si.si_os_version & 0xff) == -1)
return -2;
break;
default:
if (file_printf(ms, ", Os %d, Version: %d.%d", si.si_os,
si.si_os_version & 0xff,
(uint32_t)si.si_os_version >> 8) == -1)
return -2;
break;
}
}
if (file_printf(ms, ", %s Endian",
si.si_byte_order == 0xfffe ? "Little" : "Big") == -1)
return -1;
switch (si.si_os) {
case 2:
if (file_printf(ms, ", Os: Windows, Version %d.%d",
si.si_os_version & 0xff, si.si_os_version >> 8)
== -1)
return -1;
break;
case 1:
if (file_printf(ms, ", Os: MacOS, Version %d.%d",
si.si_os_version >> 8, si.si_os_version & 0xff)
== -1)
return -1;
break;
default:
if (file_printf(ms, ", Os %d, Version: %d.%d", si.si_os,
si.si_os_version & 0xff, si.si_os_version >> 8)
== -1)
return -1;
break;
}
}
m = cdf_file_property_info(ms, info, count);
free(info);
m = cdf_file_property_info(ms, info, count);
free(info);
return m == -1 ? -2 : m;
return m;
}
protected int
file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
size_t nbytes)
{
cdf_info_t info;
cdf_header_t h;
cdf_sat_t sat, ssat;
cdf_stream_t sst, scn;
cdf_dir_t dir;
int i;
const char *expn = "";
const char *corrupt = "corrupt: ";
cdf_info_t info;
cdf_header_t h;
cdf_sat_t sat, ssat;
cdf_stream_t sst, scn;
cdf_dir_t dir;
int i;
const char *expn = "";
info.i_fd = fd;
info.i_buf = buf;
info.i_len = nbytes;
if (ms->flags & MAGIC_APPLE)
return 0;
if (cdf_read_header(&info, &h) == -1)
return 0;
info.i_fd = fd;
info.i_buf = buf;
info.i_len = nbytes;
if (ms->flags & MAGIC_APPLE)
return 0;
if (cdf_read_header(&info, &h) == -1)
return 0;
#ifdef CDF_DEBUG
cdf_dump_header(&h);
cdf_dump_header(&h);
#endif
if ((i = cdf_read_sat(&info, &h, &sat)) == -1) {
expn = "Can't read SAT";
goto out0;
}
if ((i = cdf_read_sat(&info, &h, &sat)) == -1) {
expn = "Can't read SAT";
goto out0;
}
#ifdef CDF_DEBUG
cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
#endif
if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) {
expn = "Can't read SSAT";
goto out1;
}
if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) {
expn = "Can't read SSAT";
goto out1;
}
#ifdef CDF_DEBUG
cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
#endif
if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) {
expn = "Can't read directory";
goto out2;
}
if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) {
expn = "Can't read directory";
goto out2;
}
if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst)) == -1) {
expn = "Cannot read short stream";
goto out3;
}
if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst)) == -1) {
expn = "Cannot read short stream";
goto out3;
}
#ifdef CDF_DEBUG
cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
#endif
if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
&scn)) == -1) {
if (errno == ESRCH) {
corrupt = expn;
expn = "No summary info";
} else {
expn = "Cannot read summary info";
}
goto out4;
}
if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
&scn)) == -1) {
expn = "Cannot read summary info";
goto out4;
}
#ifdef CDF_DEBUG
cdf_dump_summary_info(&h, &scn);
cdf_dump_summary_info(&h, &scn);
#endif
if ((i = cdf_file_summary_info(ms, &h, &scn)) < 0)
expn = "Can't expand summary_info";
if (i == 0) {
const char *str = "vnd.ms-office";
cdf_directory_t *d;
char name[__arraycount(d->d_name)];
size_t j, k;
for (j = 0; j < dir.dir_len; j++) {
d = &dir.dir_tab[j];
for (k = 0; k < sizeof(name); k++)
name[k] = (char)cdf_tole2(d->d_name[k]);
if (strstr(name, "WordDocument") == 0) {
str = "msword";
break;
}
}
if (file_printf(ms, "application/%s", str) == -1)
return -1;
if ((i = cdf_file_summary_info(ms, &scn)) == -1)
expn = "Can't expand summary_info";
free(scn.sst_tab);
out4:
free(sst.sst_tab);
out3:
free(dir.dir_tab);
out2:
free(ssat.sat_tab);
out1:
free(sat.sat_tab);
out0:
if (i != 1) {
if (file_printf(ms, "CDF V2 Document") == -1)
return -1;
if (*expn)
if (file_printf(ms, ", corrupt: %s", expn) == -1)
return -1;
i = 1;
}
free(scn.sst_tab);
out4:
free(sst.sst_tab);
out3:
free(dir.dir_tab);
out2:
free(ssat.sat_tab);
out1:
free(sat.sat_tab);
out0:
if (i != 1) {
if (i == -1)
if (file_printf(ms, "Composite Document File V2 Document")
== -1)
return -1;
if (*expn)
if (file_printf(ms, ", %s%s", corrupt, expn) == -1)
return -1;
i = 1;
}
return i;
return i;
}
+107 -110
View File
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: readelf.c,v 1.90 2011/08/23 08:01:12 christos Exp $")
FILE_RCSID("@(#)$File: readelf.c,v 1.81 2008/11/04 16:38:28 christos Exp $")
#endif
#ifdef BUILTIN_ELF
@@ -47,8 +47,8 @@ private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
#endif
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
off_t, int *, int);
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t,
off_t, int *, int);
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *,
int);
private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
int, size_t, int *);
@@ -144,7 +144,7 @@ getu64(int swap, uint64_t value)
#define xsh_size (clazz == ELFCLASS32 \
? elf_getu32(swap, sh32.sh_size) \
: elf_getu64(swap, sh64.sh_size))
#define xsh_offset (off_t)(clazz == ELFCLASS32 \
#define xsh_offset (clazz == ELFCLASS32 \
? elf_getu32(swap, sh32.sh_offset) \
: elf_getu64(swap, sh64.sh_offset))
#define xsh_type (clazz == ELFCLASS32 \
@@ -283,11 +283,9 @@ private const char os_style_names[][8] = {
"NetBSD",
};
#define FLAGS_DID_CORE 0x01
#define FLAGS_DID_NOTE 0x02
#define FLAGS_DID_BUILD_ID 0x04
#define FLAGS_DID_CORE_STYLE 0x08
#define FLAGS_IS_CORE 0x10
#define FLAGS_DID_CORE 1
#define FLAGS_DID_NOTE 2
#define FLAGS_DID_CORE_STYLE 4
private int
dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
@@ -298,6 +296,13 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
size_t offset;
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
off_t savedoffset;
struct stat st;
if (fstat(fd, &st) < 0) {
file_badread(ms);
return -1;
}
if (size != xph_sizeof) {
if (file_printf(ms, ", corrupted program header size") == -1)
@@ -309,21 +314,23 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* Loop through all the program headers.
*/
for ( ; num; num--) {
if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
if ((savedoffset = lseek(fd, off, SEEK_SET)) == (off_t)-1) {
file_badseek(ms);
return -1;
}
if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) {
if (read(fd, xph_addr, xph_sizeof) == -1) {
file_badread(ms);
return -1;
}
off += size;
if (xph_offset > fsize) {
/* Perhaps warn here */
if (lseek(fd, savedoffset, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
continue;
}
off += size;
if (xph_type != PT_NOTE)
continue;
@@ -331,11 +338,11 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
bufsize = FINFO_READ_FUNC(fd, nbuf,
bufsize = read(fd, nbuf,
((xph_filesz < sizeof(nbuf)) ? xph_filesz : sizeof(nbuf)));
if (bufsize == -1) {
file_badread(ms);
@@ -411,8 +418,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
return (offset >= size) ? offset : size;
}
if ((*flags & (FLAGS_DID_NOTE|FLAGS_DID_BUILD_ID)) ==
(FLAGS_DID_NOTE|FLAGS_DID_BUILD_ID))
if (*flags & FLAGS_DID_NOTE)
goto core;
if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
@@ -454,19 +460,6 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
return size;
}
if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
xnh_type == NT_GNU_BUILD_ID && (descsz == 16 || descsz == 20)) {
uint32_t desc[5], i;
if (file_printf(ms, ", BuildID[%s]=0x", descsz == 16 ? "md5/uuid" :
"sha1") == -1)
return size;
(void)memcpy(desc, &nbuf[doff], descsz);
for (i = 0; i < descsz >> 2; i++)
if (file_printf(ms, "%.8x", desc[i]) == -1)
return size;
*flags |= FLAGS_DID_BUILD_ID;
}
if (namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0 &&
xnh_type == NT_NETBSD_VERSION && descsz == 4) {
uint32_t desc;
@@ -682,7 +675,7 @@ core:
break;
default:
if (xnh_type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {
if (xnh_type == NT_PRPSINFO) {
size_t i, j;
unsigned char c;
/*
@@ -699,7 +692,6 @@ core:
unsigned char *cname, *cp;
size_t reloffset = prpsoffsets(i);
size_t noffset = doff + reloffset;
size_t k;
for (j = 0; j < 16; j++, noffset++,
reloffset++) {
/*
@@ -745,24 +737,6 @@ core:
/*
* Well, that worked.
*/
/*
* Try next offsets, in case this match is
* in the middle of a string.
*/
for (k = i + 1 ; k < NOFFSETS ; k++) {
size_t no;
int adjust = 1;
if (prpsoffsets(k) >= prpsoffsets(i))
continue;
for (no = doff + prpsoffsets(k);
no < doff + prpsoffsets(i); no++)
adjust = adjust
&& isprint(nbuf[no]);
if (adjust)
i = k;
}
cname = (unsigned char *)
&nbuf[doff + prpsoffsets(i)];
for (cp = cname; *cp && isprint(*cp); cp++)
@@ -841,13 +815,13 @@ static const cap_desc_t cap_desc_386[] = {
private int
doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
size_t size, off_t fsize, int *flags, int mach)
size_t size, int *flags, int mach)
{
Elf32_Shdr sh32;
Elf64_Shdr sh64;
int stripped = 1;
void *nbuf;
off_t noff, coff;
off_t noff;
uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */
uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */
@@ -857,18 +831,16 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
return 0;
}
if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
for ( ; num; num--) {
if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
if (FINFO_READ_FUNC(fd, xsh_addr, xsh_sizeof) == -1) {
if (read(fd, xsh_addr, xsh_sizeof) == -1) {
file_badread(ms);
return -1;
}
off += size;
/* Things we can determine before we seek */
switch (xsh_type) {
case SHT_SYMTAB:
#if 0
@@ -876,25 +848,20 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
#endif
stripped = 0;
break;
default:
if (xsh_offset > fsize) {
/* Perhaps warn here */
continue;
}
break;
}
/* Things we can determine when we seek */
switch (xsh_type) {
case SHT_NOTE:
if ((off = lseek(fd, (off_t)0, SEEK_CUR)) ==
(off_t)-1) {
file_badread(ms);
return -1;
}
nbuf = emalloc((size_t)xsh_size);
if ((noff = FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET)) ==
if ((noff = lseek(fd, (off_t)xsh_offset, SEEK_SET)) ==
(off_t)-1) {
file_badread(ms);
efree(nbuf);
return -1;
}
if (FINFO_READ_FUNC(fd, nbuf, (size_t)xsh_size) !=
if (read(fd, nbuf, (size_t)xsh_size) !=
(ssize_t)xsh_size) {
efree(nbuf);
file_badread(ms);
@@ -911,12 +878,24 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
if (noff == 0)
break;
}
if ((lseek(fd, off, SEEK_SET)) == (off_t)-1) {
efree(nbuf);
file_badread(ms);
return -1;
}
efree(nbuf);
break;
case SHT_SUNW_cap:
if (FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET) ==
{
off_t coff;
if ((off = lseek(fd, (off_t)0, SEEK_CUR)) ==
(off_t)-1) {
file_badseek(ms);
file_badread(ms);
return -1;
}
if (lseek(fd, (off_t)xsh_offset, SEEK_SET) ==
(off_t)-1) {
file_badread(ms);
return -1;
}
coff = 0;
@@ -925,9 +904,9 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
Elf64_Cap cap64;
char cbuf[/*CONSTCOND*/
MAX(sizeof cap32, sizeof cap64)];
if ((coff += xcap_sizeof) > (off_t)xsh_size)
if ((coff += xcap_sizeof) >= (off_t)xsh_size)
break;
if (FINFO_READ_FUNC(fd, cbuf, (size_t)xcap_sizeof) !=
if (read(fd, cbuf, (size_t)xcap_sizeof) !=
(ssize_t)xcap_sizeof) {
file_badread(ms);
return -1;
@@ -945,18 +924,19 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
default:
if (file_printf(ms,
", with unknown capability "
"0x%" INT64_T_FORMAT "x = 0x%"
INT64_T_FORMAT "x",
"0x%llx = 0x%llx",
(unsigned long long)xcap_tag,
(unsigned long long)xcap_val) == -1)
return -1;
break;
}
}
if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
file_badread(ms);
return -1;
}
break;
default:
break;
}
}
}
if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
@@ -992,13 +972,12 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
}
if (cap_hw1)
if (file_printf(ms,
" unknown hardware capability 0x%"
INT64_T_FORMAT "x",
" unknown hardware capability 0x%llx",
(unsigned long long)cap_hw1) == -1)
return -1;
} else {
if (file_printf(ms,
" hardware capability 0x%" INT64_T_FORMAT "x",
" hardware capability 0x%llx",
(unsigned long long)cap_hw1) == -1)
return -1;
}
@@ -1014,8 +993,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
cap_sf1 &= ~SF1_SUNW_MASK;
if (cap_sf1)
if (file_printf(ms,
", with unknown software capability 0x%"
INT64_T_FORMAT "x",
", with unknown software capability 0x%llx",
(unsigned long long)cap_sf1) == -1)
return -1;
}
@@ -1036,8 +1014,15 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
const char *linking_style = "statically";
const char *shared_libraries = "";
unsigned char nbuf[BUFSIZ];
ssize_t bufsize;
int bufsize;
size_t offset, align;
off_t savedoffset = (off_t)-1;
struct stat st;
if (fstat(fd, &st) < 0) {
file_badread(ms);
return -1;
}
if (size != xph_sizeof) {
if (file_printf(ms, ", corrupted program header size") == -1)
@@ -1045,20 +1030,37 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
return 0;
}
for ( ; num; num--) {
if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) {
for ( ; num; num--) {
if (read(fd, xph_addr, xph_sizeof) == -1) {
file_badread(ms);
return -1;
}
if (xph_offset > st.st_size && savedoffset != (off_t)-1) {
if (lseek(fd, savedoffset, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
continue;
}
off += size;
if ((savedoffset = lseek(fd, (off_t)0, SEEK_CUR)) == (off_t)-1) {
file_badseek(ms);
return -1;
}
if (xph_offset > fsize) {
if (lseek(fd, savedoffset, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
continue;
}
/* Things we can determine before we seek */
switch (xph_type) {
case PT_DYNAMIC:
linking_style = "dynamically";
@@ -1066,18 +1068,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
case PT_INTERP:
shared_libraries = " (uses shared libs)";
break;
default:
if (xph_offset > fsize) {
/* Maybe warn here? */
continue;
}
break;
}
/* Things we can determine when we seek */
switch (xph_type) {
case PT_NOTE:
if ((align = xph_align) & 0x80000000UL) {
if ((align = xph_align) & 0x80000000) {
if (file_printf(ms,
", invalid note alignment 0x%lx",
(unsigned long)align) == -1)
@@ -1090,11 +1082,12 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
* This is a PT_NOTE section; loop through all the notes
* in the section.
*/
if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) {
if (lseek(fd, xph_offset, SEEK_SET)
== (off_t)-1) {
file_badseek(ms);
return -1;
}
bufsize = FINFO_READ_FUNC(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ?
bufsize = read(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ?
xph_filesz : sizeof(nbuf)));
if (bufsize == -1) {
file_badread(ms);
@@ -1110,6 +1103,10 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
if (offset == 0)
break;
}
if (lseek(fd, savedoffset, SEEK_SET) == (off_t)-1) {
file_badseek(ms);
return -1;
}
break;
default:
break;
@@ -1156,7 +1153,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
/*
* If we cannot seek, it must be a pipe, socket or fifo.
*/
if((FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
fd = file_pipe2file(ms, fd, buf, nbytes);
if (fstat(fd, &st) == -1) {
+30 -51
View File
@@ -32,7 +32,7 @@
* Note: cobbled from the linux header file, with modifications
*/
#ifndef __fake_elf_h__
#define __fake_elf_h__
#define __fake_elf_h__
#if HAVE_STDINT_H
#include <stdint.h>
@@ -45,7 +45,7 @@ typedef uint32_t Elf32_Word;
typedef uint8_t Elf32_Char;
#if SIZEOF_LONG_LONG != 8
#define USE_ARRAY_FOR_64BIT_TYPES
#define USE_ARRAY_FOR_64BIT_TYPES
typedef uint32_t Elf64_Addr[2];
typedef uint32_t Elf64_Off[2];
typedef uint32_t Elf64_Xword[2];
@@ -59,7 +59,7 @@ typedef uint16_t Elf64_Half;
typedef uint32_t Elf64_Word;
typedef uint8_t Elf64_Char;
#define EI_NIDENT 16
#define EI_NIDENT 16
typedef struct {
Elf32_Char e_ident[EI_NIDENT];
@@ -96,10 +96,10 @@ typedef struct {
} Elf64_Ehdr;
/* e_type */
#define ET_REL 1
#define ET_EXEC 2
#define ET_DYN 3
#define ET_CORE 4
#define ET_REL 1
#define ET_EXEC 2
#define ET_DYN 3
#define ET_CORE 4
/* e_machine (used only for SunOS 5.x hardware capabilities) */
#define EM_SPARC 2
@@ -110,20 +110,20 @@ typedef struct {
#define EM_AMD64 62
/* sh_type */
#define SHT_SYMTAB 2
#define SHT_NOTE 7
#define SHT_DYNSYM 11
#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilites */
#define SHT_SYMTAB 2
#define SHT_NOTE 7
#define SHT_DYNSYM 11
#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilites */
/* elf type */
#define ELFDATANONE 0 /* e_ident[EI_DATA] */
#define ELFDATA2LSB 1
#define ELFDATA2MSB 2
#define ELFDATANONE 0 /* e_ident[EI_DATA] */
#define ELFDATA2LSB 1
#define ELFDATA2MSB 2
/* elf class */
#define ELFCLASSNONE 0
#define ELFCLASS32 1
#define ELFCLASS64 2
#define ELFCLASSNONE 0
#define ELFCLASS32 1
#define ELFCLASS64 2
/* magic number */
#define EI_MAG0 0 /* e_ident[] indexes */
@@ -221,47 +221,26 @@ typedef struct {
#define NT_PRFPREG 2
#define NT_PRPSINFO 3
#define NT_PRXREG 4
#define NT_TASKSTRUCT 4
#define NT_TASKSTRUCT 4
#define NT_PLATFORM 5
#define NT_AUXV 6
/* Note types used in executables */
/* NetBSD executables (name = "NetBSD") */
#define NT_NETBSD_VERSION 1
#define NT_NETBSD_EMULATION 2
#define NT_FREEBSD_VERSION 1
#define NT_OPENBSD_VERSION 1
#define NT_DRAGONFLY_VERSION 1
/*
* GNU executables (name = "GNU")
* word[0]: GNU OS tags
* word[1]: major version
* word[2]: minor version
* word[3]: tiny version
*/
#define NT_GNU_VERSION 1
#define NT_NETBSD_VERSION 1
#define NT_NETBSD_EMULATION 2
#define NT_FREEBSD_VERSION 1
#define NT_OPENBSD_VERSION 1
#define NT_DRAGONFLY_VERSION 1
/* GNU executables (name = "GNU") */
#define NT_GNU_VERSION 1
/* GNU OS tags */
#define GNU_OS_LINUX 0
#define GNU_OS_HURD 1
#define GNU_OS_SOLARIS 2
#define GNU_OS_KFREEBSD 3
#define GNU_OS_KNETBSD 4
/*
* GNU Hardware capability information
* word[0]: Number of entries
* word[1]: Bitmask of enabled entries
* Followed by a byte id, and a NUL terminated string per entry
*/
#define NT_GNU_HWCAP 2
/*
* GNU Build ID generated by ld
* 160 bit SHA1 [default]
* 128 bit md5 or uuid
*/
#define NT_GNU_BUILD_ID 3
#define GNU_OS_LINUX 0
#define GNU_OS_HURD 1
#define GNU_OS_SOLARIS 2
#define GNU_OS_KFREEBSD 3
#define GNU_OS_KNETBSD 4
/* SunOS 5.x hardware/software capabilities */
typedef struct {
+87 -93
View File
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
FILE_RCSID("@(#)$File: softmagic.c,v 1.147 2011/11/05 15:44:22 rrt Exp $")
FILE_RCSID("@(#)$File: softmagic.c,v 1.135 2009/03/27 22:42:49 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -48,9 +48,9 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.147 2011/11/05 15:44:22 rrt Exp $")
private int match(struct magic_set *, struct magic *, uint32_t,
const unsigned char *, size_t, int, int);
const unsigned char *, size_t, int);
private int mget(struct magic_set *, const unsigned char *,
struct magic *, size_t, unsigned int, int);
struct magic *, size_t, unsigned int);
private int magiccheck(struct magic_set *, struct magic *);
private int32_t mprint(struct magic_set *, struct magic *);
private int32_t moffset(struct magic_set *, struct magic *);
@@ -71,14 +71,12 @@ private void cvt_64(union VALUETYPE *, const struct magic *);
*/
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
protected int
file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
int mode, int text)
file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes, int mode)
{
struct mlist *ml;
int rv;
for (ml = ms->mlist->next; ml != ms->mlist; ml = ml->next)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, mode,
text)) != 0)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, mode)) != 0)
return rv;
return 0;
@@ -113,7 +111,7 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
*/
private int
match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
const unsigned char *s, size_t nbytes, int mode, int text)
const unsigned char *s, size_t nbytes, int mode)
{
uint32_t magindex = 0;
unsigned int cont_level = 0;
@@ -130,10 +128,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
int flush = 0;
struct magic *m = &magic[magindex];
if ((IS_LIBMAGIC_STRING(m->type) &&
((text && (m->str_flags & (STRING_BINTEST | STRING_TEXTTEST)) == STRING_BINTEST) ||
(!text && (m->str_flags & (STRING_TEXTTEST | STRING_BINTEST)) == STRING_TEXTTEST))) ||
(m->flag & mode) != mode) {
if ((m->flag & BINTEST) != mode) {
/* Skip sub-tests */
while (magindex < nmagic - 1 && magic[magindex + 1].cont_level != 0) {
magindex++;
@@ -145,7 +140,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
ms->line = m->lineno;
/* if main entry matches, print it... */
switch (mget(ms, s, m, nbytes, cont_level, text)) {
switch (mget(ms, s, m, nbytes, cont_level)) {
case -1:
return -1;
case 0:
@@ -154,7 +149,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
default:
if (m->type == FILE_INDIRECT)
returnval = 1;
switch (magiccheck(ms, m)) {
case -1:
return -1;
@@ -178,8 +173,6 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
continue;
}
if ((e = handle_annotation(ms, m)) != 0)
return e;
/*
* If we are going to print something, we'll need to print
* a blank before we print something else.
@@ -187,6 +180,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
if (*m->desc) {
need_separator = 1;
printed_something = 1;
if ((e = handle_annotation(ms, m)) != 0)
return e;
if (print_sep(ms, firstline) == -1)
return -1;
}
@@ -227,7 +222,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
continue;
}
#endif
switch (mget(ms, s, m, nbytes, cont_level, text)) {
switch (mget(ms, s, m, nbytes, cont_level)) {
case -1:
return -1;
case 0:
@@ -260,13 +255,13 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
ms->c.li[cont_level].got_match = 0;
break;
}
if ((e = handle_annotation(ms, m)) != 0)
return e;
/*
* If we are going to print something,
* make sure that we have a separator first.
*/
if (*m->desc) {
if ((e = handle_annotation(ms, m)) != 0)
return e;
if (!printed_something) {
printed_something = 1;
if (print_sep(ms, firstline)
@@ -436,7 +431,7 @@ mprint(struct magic_set *ms, struct magic *m)
return -1;
t = ms->offset + strlen(p->s);
if (m->type == FILE_PSTRING)
t += file_pstring_length_size(m);
t++;
}
break;
@@ -566,23 +561,23 @@ moffset(struct magic_set *ms, struct magic *m)
{
switch (m->type) {
case FILE_BYTE:
return CAST(int32_t, (ms->offset + sizeof(char)));
return ms->offset + sizeof(char);
case FILE_SHORT:
case FILE_BESHORT:
case FILE_LESHORT:
return CAST(int32_t, (ms->offset + sizeof(short)));
return ms->offset + sizeof(short);
case FILE_LONG:
case FILE_BELONG:
case FILE_LELONG:
case FILE_MELONG:
return CAST(int32_t, (ms->offset + sizeof(int32_t)));
return ms->offset + sizeof(int32_t);
case FILE_QUAD:
case FILE_BEQUAD:
case FILE_LEQUAD:
return CAST(int32_t, (ms->offset + sizeof(int64_t)));
return ms->offset + sizeof(int64_t);
case FILE_STRING:
case FILE_PSTRING:
@@ -596,9 +591,9 @@ moffset(struct magic_set *ms, struct magic *m)
if (*m->value.s == '\0')
p->s[strcspn(p->s, "\n")] = '\0';
t = CAST(uint32_t, (ms->offset + strlen(p->s)));
t = ms->offset + strlen(p->s);
if (m->type == FILE_PSTRING)
t += file_pstring_length_size(m);
t++;
return t;
}
@@ -606,46 +601,46 @@ moffset(struct magic_set *ms, struct magic *m)
case FILE_BEDATE:
case FILE_LEDATE:
case FILE_MEDATE:
return CAST(int32_t, (ms->offset + sizeof(time_t)));
return ms->offset + sizeof(time_t);
case FILE_LDATE:
case FILE_BELDATE:
case FILE_LELDATE:
case FILE_MELDATE:
return CAST(int32_t, (ms->offset + sizeof(time_t)));
return ms->offset + sizeof(time_t);
case FILE_QDATE:
case FILE_BEQDATE:
case FILE_LEQDATE:
return CAST(int32_t, (ms->offset + sizeof(uint64_t)));
return ms->offset + sizeof(uint64_t);
case FILE_QLDATE:
case FILE_BEQLDATE:
case FILE_LEQLDATE:
return CAST(int32_t, (ms->offset + sizeof(uint64_t)));
return ms->offset + sizeof(uint64_t);
case FILE_FLOAT:
case FILE_BEFLOAT:
case FILE_LEFLOAT:
return CAST(int32_t, (ms->offset + sizeof(float)));
return ms->offset + sizeof(float);
case FILE_DOUBLE:
case FILE_BEDOUBLE:
case FILE_LEDOUBLE:
return CAST(int32_t, (ms->offset + sizeof(double)));
return ms->offset + sizeof(double);
break;
case FILE_REGEX:
if ((m->str_flags & REGEX_OFFSET_START) != 0)
return CAST(int32_t, ms->search.offset);
return ms->search.offset;
else
return CAST(int32_t, (ms->search.offset +
ms->search.rm_len));
return ms->search.offset + ms->search.rm_len;
case FILE_SEARCH:
if ((m->str_flags & REGEX_OFFSET_START) != 0)
return CAST(int32_t, ms->search.offset);
return ms->search.offset;
else
return CAST(int32_t, (ms->search.offset + m->vallen));
return ms->search.offset + m->vallen;
case FILE_DEFAULT:
return ms->offset;
@@ -774,16 +769,28 @@ mconvert(struct magic_set *ms, struct magic *m)
case FILE_LESTRING16: {
/* Null terminate and eat *trailing* return */
p->s[sizeof(p->s) - 1] = '\0';
#if 0
/* Why? breaks magic numbers that end with \xa */
len = strlen(p->s);
if (len-- && p->s[len] == '\n')
p->s[len] = '\0';
#endif
return 1;
}
case FILE_PSTRING: {
char *ptr1 = p->s, *ptr2 = ptr1 + file_pstring_length_size(m);
size_t len = file_pstring_get_length(m, ptr1);
char *ptr1 = p->s, *ptr2 = ptr1 + 1;
size_t len = *p->s;
if (len >= sizeof(p->s))
len = sizeof(p->s) - 1;
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
#if 0
/* Why? breaks magic numbers that end with \xa */
len = strlen(p->s);
if (len-- && p->s[len] == '\n')
p->s[len] = '\0';
#endif
return 1;
}
case FILE_BESHORT:
@@ -896,7 +903,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (indir == 0) {
switch (type) {
case FILE_SEARCH:
ms->search.s = RCAST(const char *, s) + offset;
ms->search.s = (const char *)s + offset;
ms->search.s_len = nbytes - offset;
ms->search.offset = offset;
return 0;
@@ -914,21 +921,18 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
ms->search.s = NULL;
return 0;
}
buf = RCAST(const char *, s) + offset;
end = last = RCAST(const char *, s) + nbytes;
buf = (const char *)s + offset;
end = last = (const char *)s + nbytes;
/* mget() guarantees buf <= last */
for (lines = linecnt, b = buf; lines && b < end &&
((b = CAST(const char *,
memchr(c = b, '\n', CAST(size_t, (end - b)))))
|| (b = CAST(const char *,
memchr(c, '\r', CAST(size_t, (end - c))))));
for (lines = linecnt, b = buf;
lines && ((b = memchr(c = b, '\n', end - b)) || (b = memchr(c, '\r', end - c)));
lines--, b++) {
last = b;
if (b[0] == '\r' && b[1] == '\n')
b++;
}
if (lines)
last = RCAST(const char *, s) + nbytes;
last = (const char *)s + nbytes;
ms->search.s = buf;
ms->search.s_len = last - buf;
@@ -997,7 +1001,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
private int
mget(struct magic_set *ms, const unsigned char *s,
struct magic *m, size_t nbytes, unsigned int cont_level, int text)
struct magic *m, size_t nbytes, unsigned int cont_level)
{
uint32_t offset = ms->offset;
uint32_t count = m->str_range;
@@ -1551,12 +1555,12 @@ mget(struct magic_set *ms, const unsigned char *s,
case FILE_INDIRECT:
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
file_printf(ms, "%s", m->desc) == -1)
file_printf(ms, m->desc) == -1)
return -1;
if (nbytes < offset)
return 0;
return file_softmagic(ms, s + offset, nbytes - offset,
BINTEST, text);
BINTEST);
case FILE_DEFAULT: /* nothing to check */
default:
@@ -1602,20 +1606,19 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
if ((v = toupper(*b++) - *a++) != '\0')
break;
}
else if ((flags & STRING_COMPACT_WHITESPACE) &&
else if ((flags & STRING_COMPACT_BLANK) &&
isspace(*a)) {
a++;
if (isspace(*b++)) {
if (!isspace(*a))
while (isspace(*b))
b++;
while (isspace(*b))
b++;
}
else {
v = 1;
break;
}
}
else if ((flags & STRING_COMPACT_OPTIONAL_WHITESPACE) &&
else if ((flags & STRING_COMPACT_OPTIONAL_BLANK) &&
isspace(*a)) {
a++;
while (isspace(*b))
@@ -1642,7 +1645,7 @@ file_strncmp16(const char *a, const char *b, size_t len, uint32_t flags)
return file_strncmp(a, b, len, flags);
}
public void
private void
convert_libmagic_pattern(zval *pattern, int options)
{
int i, j=0;
@@ -1689,12 +1692,12 @@ convert_libmagic_pattern(zval *pattern, int options)
t[j++] = '~';
if (options & PCRE_CASELESS)
t[j++] = 'i';
t[j++] = 'm';
if (options & PCRE_MULTILINE)
t[j++] = 'm';
t[j++] = 'i';
t[j]='\0';
t[j]=0;
Z_STRVAL_P(pattern) = t;
Z_STRLEN_P(pattern) = j;
@@ -1873,7 +1876,6 @@ magiccheck(struct magic_set *ms, struct magic *m)
convert_libmagic_pattern(pattern, options);
l = 0;
#if (PHP_MAJOR_VERSION < 6)
if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
#else
@@ -2024,42 +2026,40 @@ magiccheck(struct magic_set *ms, struct magic *m)
switch (m->reln) {
case 'x':
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"u == *any* = 1\n", (unsigned long long)v);
(void) fprintf(stderr, "%llu == *any* = 1\n",
(uint64_t)v);
matched = 1;
break;
case '!':
matched = v != l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT "u != %"
INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
(unsigned long long)l, matched);
(void) fprintf(stderr, "%llu != %llu = %d\n",
(uint64_t)v, (uint64_t)l,
matched);
break;
case '=':
matched = v == l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT "u == %"
INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
(unsigned long long)l, matched);
(void) fprintf(stderr, "%llu == %llu = %d\n",
(uint64_t)v, (uint64_t)l,
matched);
break;
case '>':
if (m->flag & UNSIGNED) {
matched = v > l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"u > %" INT64_T_FORMAT "u = %d\n",
(unsigned long long)v,
(unsigned long long)l, matched);
(void) fprintf(stderr, "%llu > %llu = %d\n",
(uint64_t)v,
(uint64_t)l, matched);
}
else {
matched = (int64_t) v > (int64_t) l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"d > %" INT64_T_FORMAT "d = %d\n",
(long long)v, (long long)l, matched);
(void) fprintf(stderr, "%lld > %lld = %d\n",
(uint64_t)v, (uint64_t)l, matched);
}
break;
@@ -2067,38 +2067,32 @@ magiccheck(struct magic_set *ms, struct magic *m)
if (m->flag & UNSIGNED) {
matched = v < l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"u < %" INT64_T_FORMAT "u = %d\n",
(unsigned long long)v,
(unsigned long long)l, matched);
(void) fprintf(stderr, "%llu < %llu = %d\n",
(uint64_t)v,
(uint64_t)l, matched);
}
else {
matched = (int64_t) v < (int64_t) l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"d < %" INT64_T_FORMAT "d = %d\n",
(long long)v, (long long)l, matched);
(void) fprintf(stderr, "%lld < %lld = %d\n",
(int64_t)v, (int64_t)l, matched);
}
break;
case '&':
matched = (v & l) == l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
INT64_T_FORMAT "x) == %" INT64_T_FORMAT
"x) = %d\n", (unsigned long long)v,
(unsigned long long)l, (unsigned long long)l,
matched);
(void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n",
(uint64_t)v, (uint64_t)l,
(uint64_t)l, matched);
break;
case '^':
matched = (v & l) != l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
INT64_T_FORMAT "x) != %" INT64_T_FORMAT
"x) = %d\n", (unsigned long long)v,
(unsigned long long)l, (unsigned long long)l,
matched);
(void) fprintf(stderr, "((%llx & %llx) != %llx) = %d\n",
(uint64_t)v, (uint64_t)l,
(uint64_t)l, matched);
break;
default:
+4 -4
View File
@@ -2,7 +2,7 @@
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -32,7 +32,7 @@
*
* Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
*
* $File: tar.h,v 1.13 2010/11/30 14:58:53 rrt Exp $ # checkin only
* $File: tar.h,v 1.12 2008/02/07 00:58:52 christos Exp $ # checkin only
*/
/*
@@ -49,7 +49,7 @@
#define TGNMLEN 32
union record {
unsigned char charptr[RECORDSIZE];
char charptr[RECORDSIZE];
struct header {
char name[NAMSIZ];
char mode[8];
-14
View File
@@ -1,14 +0,0 @@
--TEST--
Bug #61173: Unable to detect error from finfo constructor
--SKIPIF--
<?php
if (!class_exists('finfo'))
die('skip no fileinfo extension');
--FILE--
<?php
$finfo = new finfo(1, '', false);
var_dump($finfo);
--EXPECTF--
Warning: finfo::finfo() expects at most 2 parameters, 3 given in %s on line %d
NULL
+1 -1
View File
@@ -25,6 +25,6 @@ var_dump( finfo_file( $finfo, $magicFile ) );
--EXPECTF--
*** Testing finfo_file() : basic functionality ***
string(28) "text/x-php; charset=us-ascii"
string(22) "PHP script, ASCII text"
string(15) "PHP script text"
string(32) "text/plain; charset=unknown-8bit"
===DONE===
+1 -19
View File
@@ -14,28 +14,10 @@ var_dump(finfo_open(FILEINFO_MIME, '/foo/bar/inexistent'));
?>
--EXPECTF--
Warning: finfo_open() expects parameter 2 to be a valid path, string given in %s on line %d
Warning: finfo_open(): Failed to load magic database at ''. in %s on line %d
bool(false)
resource(%d) of type (file_info)
resource(%d) of type (file_info)
Warning: finfo_open(%s123): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(%s123): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(): Failed to load magic database at '%s123'. in %s on line %d
bool(false)
Warning: finfo_open(%s1): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(%s1): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(): Failed to load magic database at '%s1'. in %s on line %d
bool(false)
Warning: finfo_open(%sinexistent): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(%sinexistent): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(): Failed to load magic database at '%sinexistent'. in %s on line %d
bool(false)
+4 -9
View File
@@ -26,12 +26,6 @@ var_dump( new finfo('foobar') );
===DONE===
--EXPECTF--
*** Testing finfo_open() : error functionality ***
Warning: finfo_open(%sfoobarfile): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(%sfoobarfile): failed to open stream: No such file or directory in %s on line %d
Warning: finfo_open(): Failed to load magic database at '%sfoobarfile'. in %s on line %d
bool(false)
Warning: finfo_open() expects parameter 1 to be long, array given in %s on line %d
@@ -43,9 +37,10 @@ bool(false)
Notice: finfo_open(): Warning: using regular magic file `%s' in %s on line %d
resource(%d) of type (file_info)
Warning: finfo_open() expects parameter 1 to be long, string given in %s on line %d
Warning: finfo_open() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d
bool(false)
Warning: finfo::finfo() expects parameter 1 to be long, string given in %s on line %d
NULL
Warning: finfo::finfo() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d
object(finfo)#%d (%d) {
}
===DONE===
+528 -1597
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -318,7 +318,7 @@ PHP_MINFO_FUNCTION(filter)
{
php_info_print_table_start();
php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" );
php_info_print_table_row( 2, "Revision", "$Id$");
php_info_print_table_row( 2, "Revision", "$Revision$");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
+1 -1
View File
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
/* $Revision$ */
#ifndef PHP_ICONV_H
#define PHP_ICONV_H
-1
View File
@@ -321,7 +321,6 @@ query_loop:
heap_p = heap_buf + res_size;
}
result += 2;
*(result+line_len) = 0;
snprintf(heap_p, heap_buf_size - (heap_buf - heap_p), "%s\n", result);
heap_p += line_len +2;
goto query_loop; /* repeat until result is exhausted */
+1 -2
View File
@@ -1125,8 +1125,7 @@ PHP_FUNCTION(ibase_drop_db)
PHP_FUNCTION(ibase_trans)
{
unsigned short i, link_cnt = 0, tpb_len = 0;
int argn;
unsigned short i, argn, link_cnt = 0, tpb_len = 0;
char last_tpb[TPB_MAX_SIZE];
ibase_db_link **ib_link = NULL;
ibase_trans *ib_trans;
+1 -1
View File
@@ -54,6 +54,6 @@ UBreakIterator*
grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status TSRMLS_DC );
/* OUTSIDE_STRING: check if (possibly negative) long offset is outside the string with int32_t length */
#define OUTSIDE_STRING(offset, max_len) ( offset <= INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (long) max_len : offset >= (long) max_len) )
#define OUTSIDE_STRING(offset, max_len) ( offset < INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (long) max_len : offset >= (long) max_len) )
#endif // GRAPHEME_GRAPHEME_UTIL_H
-11
View File
@@ -1,11 +0,0 @@
--TEST--
grapheme() str[i]pos limits
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php
var_dump(grapheme_stripos(1,1,2147483648));
var_dump(grapheme_strpos(1,1,2147483648));
--EXPECT--
bool(false)
bool(false)
+1 -2
View File
@@ -1,8 +1,7 @@
--TEST--
create() icu <= 4.2
create()
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?>
--FILE--
<?php
-82
View File
@@ -1,82 +0,0 @@
--TEST--
create() icu >= 4.8
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
--FILE--
<?php
/*
* Try creating collator with different locales
* with Procedural and Object methods.
*/
function ut_main()
{
$res_str = '';
$locales = array(
'EN-US-ODESSA',
'UK_UA_ODESSA',
'uk-ua_CALIFORNIA@currency=;currency=GRN',
'',
'root',
'uk@currency=EURO',
'1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799'
);
foreach( $locales as $locale )
{
// Create Collator with the current locale.
$coll = ut_coll_create( $locale );
if( !is_object($coll) )
{
$res_str .= "Error creating collator with '$locale' locale: " .
intl_get_error_message() . "\n";
continue;
}
// Get the requested, valid and actual locales.
$vloc = ut_coll_get_locale( $coll, Locale::VALID_LOCALE );
$aloc = ut_coll_get_locale( $coll, Locale::ACTUAL_LOCALE );
// Show them.
$res_str .= "Locale: '$locale'\n" .
" ULOC_REQUESTED_LOCALE = '$locale'\n" .
" ULOC_VALID_LOCALE = '$vloc'\n" .
" ULOC_ACTUAL_LOCALE = '$aloc'\n";
}
return $res_str;
}
include_once( 'ut_common.inc' );
ut_run();
?>
--EXPECTF--
Locale: 'EN-US-ODESSA'
ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA'
ULOC_VALID_LOCALE = 'en_US'
ULOC_ACTUAL_LOCALE = 'root'
Locale: 'UK_UA_ODESSA'
ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA'
ULOC_VALID_LOCALE = 'uk_UA'
ULOC_ACTUAL_LOCALE = 'uk'
Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN'
ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN'
ULOC_VALID_LOCALE = 'uk_UA'
ULOC_ACTUAL_LOCALE = 'uk'
Locale: ''
ULOC_REQUESTED_LOCALE = ''
ULOC_VALID_LOCALE = '%s'
ULOC_ACTUAL_LOCALE = '%s'
Locale: 'root'
ULOC_REQUESTED_LOCALE = 'root'
ULOC_VALID_LOCALE = 'root'
ULOC_ACTUAL_LOCALE = 'root'
Locale: 'uk@currency=EURO'
ULOC_REQUESTED_LOCALE = 'uk@currency=EURO'
ULOC_VALID_LOCALE = 'uk'
ULOC_ACTUAL_LOCALE = 'uk'
Error creating collator with '1234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than 80 characters: U_ILLEGAL_ARGUMENT_ERROR
Loaded 100 of 316 files, more files were not shown because too many files have changed in this diff. Show more