Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27886 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94171 invoked by uid 1010); 7 Feb 2007 17:27:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 94155 invoked from network); 7 Feb 2007 17:27:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Feb 2007 17:27:14 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 66.79.163.178 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 66.79.163.178 bluga.net Linux 2.5 (sometimes 2.4) (4) Received: from [66.79.163.178] ([66.79.163.178:45467] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D4/04-18288-2FB0AC54 for ; Wed, 07 Feb 2007 12:27:14 -0500 Received: from mail.bluga.net (mail.bluga.net [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id B4D118738E for ; Wed, 7 Feb 2007 09:11:03 -0800 (PST) Received: from [192.168.0.106] (CPE-24-169-242-149.neb.res.rr.com [24.169.242.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 5DB3E87362 for ; Wed, 7 Feb 2007 09:11:03 -0800 (PST) Message-ID: <45CA0822.2020100@chiaraquartet.net> Date: Wed, 07 Feb 2007 11:10:58 -0600 User-Agent: Thunderbird 1.5.0.9 (X11/20070104) MIME-Version: 1.0 To: internals Mailing List Content-Type: multipart/mixed; boundary="------------090001020109030908020606" X-Virus-Scanned: ClamAV using ClamSMTP Subject: [PATCH] version 2, __HALT_COMPILER(); From: greg@chiaraquartet.net (Gregory Beaver) --------------090001020109030908020606 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, The last patch version still allowed: which would break any __HALT_COMPILER(); Interestingly enough, the current implementation makes this script a fatal error: But not at the first define, instead it does at the __HALT_COMPILER();. Once again a bug, as it should instead give a notice that __COMPILER_HALT_OFFSET__ is already defined at the userspace define(). Greg --------------090001020109030908020606 Content-Type: text/plain; name="better_halt.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="better_halt.patch.txt" ? better_halt.patch.txt ? zlib.patch ? ext/zlib/zlib_filter.c.2 ? pear/scripts Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.647.2.27.2.29 diff -u -r1.647.2.27.2.29 zend_compile.c --- Zend/zend_compile.c 1 Feb 2007 15:23:46 -0000 1.647.2.27.2.29 +++ Zend/zend_compile.c 7 Feb 2007 17:01:13 -0000 @@ -3094,7 +3094,18 @@ zend_llist_add_element(fetch_list_ptr, &opline); } - +void zend_do_halt_compiler_register(TSRMLS_D) +{ + char *name, *cfilename; + char haltoff[] = "__COMPILER_HALT_OFFSET__"; + int len, clen; + cfilename = zend_get_compiled_filename(TSRMLS_C); + clen = strlen(cfilename); + zend_mangle_property_name(&name, &len, haltoff, + sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0); + zend_register_long_constant(name, len+1, zend_get_scanned_file_offset(TSRMLS_C), CONST_CS, 0 TSRMLS_CC); + pefree(name, 0); +} void zend_do_declare_implicit_property(TSRMLS_D) { Index: Zend/zend_compile.h =================================================================== RCS file: /repository/ZendEngine2/zend_compile.h,v retrieving revision 1.316.2.8.2.9 diff -u -r1.316.2.8.2.9 zend_compile.h --- Zend/zend_compile.h 10 Jan 2007 15:58:07 -0000 1.316.2.8.2.9 +++ Zend/zend_compile.h 7 Feb 2007 17:01:14 -0000 @@ -447,6 +447,7 @@ void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS_DC); +void zend_do_halt_compiler_register(TSRMLS_D); void zend_do_push_object(znode *object TSRMLS_DC); void zend_do_pop_object(znode *object TSRMLS_DC); Index: Zend/zend_constants.c =================================================================== RCS file: /repository/ZendEngine2/zend_constants.c,v retrieving revision 1.71.2.5.2.4 diff -u -r1.71.2.5.2.4 zend_constants.c --- Zend/zend_constants.c 1 Jan 2007 09:35:46 -0000 1.71.2.5.2.4 +++ Zend/zend_constants.c 7 Feb 2007 17:01:14 -0000 @@ -277,7 +277,7 @@ return retval; } - + if (zend_hash_find(EG(zend_constants), name, name_len+1, (void **) &c) == FAILURE) { lookup_name = estrndup(name, name_len); zend_str_tolower(lookup_name, name_len); @@ -287,7 +287,26 @@ retval=0; } } else { - retval=0; + char haltoff[] = "__COMPILER_HALT_OFFSET__"; + if (!EG(in_execution)) { + retval = 0; + } else if (name_len == sizeof("__COMPILER_HALT_OFFSET__") - 1 && memcmp(haltoff, name, name_len) == 0) { + char *cfilename, *haltname; + int len, clen; + cfilename = zend_get_executed_filename(TSRMLS_C); + clen = strlen(cfilename); + /* check for __COMPILER_HALT_OFFSET__ */ + zend_mangle_property_name(&haltname, &len, haltoff, + sizeof("__COMPILER_HALT_OFFSET__") - 1, cfilename, clen, 0); + if (zend_hash_find(EG(zend_constants), haltname, len+1, (void **) &c) == SUCCESS) { + retval = 1; + } else { + retval=0; + } + pefree(haltname, 0); + } else { + retval = 0; + } } efree(lookup_name); } @@ -326,7 +345,8 @@ name = c->name; } - if (zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { + if ((strncmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) || + zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { zend_error(E_NOTICE,"Constant %s already defined", name); free(c->name); if (!(c->flags & CONST_PERSISTENT)) { Index: Zend/zend_language_parser.y =================================================================== RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.160.2.4.2.3 diff -u -r1.160.2.4.2.3 zend_language_parser.y --- Zend/zend_language_parser.y 10 Jan 2007 15:58:07 -0000 1.160.2.4.2.3 +++ Zend/zend_language_parser.y 7 Feb 2007 17:01:15 -0000 @@ -162,7 +162,7 @@ statement | function_declaration_statement { zend_do_early_binding(TSRMLS_C); } | class_declaration_statement { zend_do_early_binding(TSRMLS_C); } - | T_HALT_COMPILER '(' ')' ';' { zval c; if (zend_get_constant("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1, &c TSRMLS_CC)) { zval_dtor(&c); zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used once per request"); } else { REGISTER_MAIN_LONG_CONSTANT("__COMPILER_HALT_OFFSET__", zend_get_scanned_file_offset(TSRMLS_C), CONST_CS); } YYACCEPT; } + | T_HALT_COMPILER '(' ')' ';' { zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; } ; --------------090001020109030908020606--