[PHP-DEV] ZendEngine2 segfault on startup

2002-09-12 Thread Lukas Schroeder

hi,

i tried to run php4-head + ZE2 but both CLI and apache(1.3)-sapi
segfault for me.

the steps i did were:

cvs co php4
cd php4
mv Zend ZE1
cvs co -d Zend ZendEngine2
./cvsclean
./buildconf
'./configure' \
  '--prefix=/usr/local/php4' \
  '--with-apxs=/usr/local/apache/bin/apxs' \
  '--disable-overload' \
  '--enable-debug' \
  $


here's the backtrace:

Starting program: /usr/local/php4/bin/php 

Program received signal SIGSEGV, Segmentation fault.
0x081b2965 in zend_objects_store_put (object=0x40172098, 
dtor=0x81b1640 zend_objects_destroy_object, clone=0)
at /home/azzit/src/cvs/php4/php4-ze2/Zend/zend_objects_API.c:47
47  EG(objects_store).free_list_head = 
EG(objects_store).object_buckets[handle].bucket.free_list.next;
(gdb) bt
#0  0x081b2965 in zend_objects_store_put (object=0x40172098, 
dtor=0x81b1640 zend_objects_destroy_object, clone=0)
at /home/azzit/src/cvs/php4/php4-ze2/Zend/zend_objects_API.c:47
#1  0x081b11bd in zend_objects_new (object=0xbfffe7c4, class_type=0x822fc98)
at /home/azzit/src/cvs/php4/php4-ze2/Zend/zend_objects.c:58
#2  0x081a379c in _object_and_properties_init (arg=0x82449d8, class_type=0x822fc98, 
properties=0x8244a08, 
__zend_filename=0x81e34a0 
/home/azzit/src/cvs/php4/php4-ze2/ext/standard/browscap.c, 
__zend_lineno=121) at /home/azzit/src/cvs/php4/php4-ze2/Zend/zend_API.c:594
#3  0x080dd42d in php_browscap_parser_cb (arg1=0xbfffe8b4, arg2=0x0, callback_type=2, 
arg=0x821a480) at /home/azzit/src/cvs/php4/php4-ze2/ext/standard/browscap.c:121
#4  0x0818790e in ini_parse () at 
/home/azzit/src/cvs/php4/php4-ze2/Zend/zend_ini_parser.y:205
#5  0x08187305 in zend_parse_ini_file (fh=0xb724, unbuffered_errors=1 '\001', 
ini_parser_cb=0x80dd280 php_browscap_parser_cb, arg=0x821a480)
at /home/azzit/src/cvs/php4/php4-ze2/Zend/zend_ini_parser.y:165
#6  0x080dd5ba in zm_startup_browscap (type=1, module_number=3)
at /home/azzit/src/cvs/php4/php4-ze2/ext/standard/browscap.c:157
#7  0x080d647b in zm_startup_basic (type=1, module_number=3)
at /home/azzit/src/cvs/php4/php4-ze2/ext/standard/basic_functions.c:997
#8  0x081a5104 in zend_startup_module (module=0x8211ca0)
at /home/azzit/src/cvs/php4/php4-ze2/Zend/zend_API.c:1020
#9  0x08164777 in php_startup_extensions (ptr=0x82199d8, count=9)
at /home/azzit/src/cvs/php4/php4-ze2/main/main.c:956
#10 0x081c1856 in php_startup_internal_extensions () at 
main/internal_functions_cli.c:67
#11 0x08164cbb in php_module_startup (sf=0x8219960)
at /home/azzit/src/cvs/php4/php4-ze2/main/main.c:1117
#12 0x081c0614 in main (argc=1, argv=0xba04)
at /home/azzit/src/cvs/php4/php4-ze2/sapi/cli/php_cli.c:424


it segfaults due to null-pointer dereference:

EG(objects_store).free_list_head = 
EG(objects_store).object_buckets[handle].bucket.free_list.next;
^

(gdb) print executor_globals.objects_store
$1 = {object_buckets = 0x0, top = 0, size = 0, free_list_head = 0}


objects_store is not initialized...


any idea whats going on?


regards,
  -lukas


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] segfault on adding empty heredoc to string

2002-09-01 Thread Lukas Schroeder

hi,

i can crash my php here by using these lines:

?php 

$a = '';
$a .= EOF
EOF;

?

can anyone second this?


regards,
  -lukas


#0  0x403218b5 in _zval_dtor (zvalue=0xbfffe214, __zend_filename=0x4038dc80
/home/azzit/src/cvs/php4/php4/Zend/zend_operators.c, __zend_lineno=1057)
at /home/azzit/src/cvs/php4/php4/Zend/zend_variables.c:43
#1  0x4031f15f in concat_function (result=0x8296a0c, op1=0x8296a0c, 
op2=0xbfffe214) at /home/azzit/src/cvs/php4/php4/Zend/zend_operators.c:1057
#2  0x40333fc0 in execute (op_array=0x829674c)
at /home/azzit/src/cvs/php4/php4/Zend/zend_execute.c:1165
#3  0x403239e4 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /home/azzit/src/cvs/php4/php4/Zend/zend.c:810


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread Lukas Schroeder

hi,

here's another shot of the current apache_hooks code.

there are some issues with startup and cleanup currently.
and the patch messes a bit with php's startup procedure.

still missing is access to array_header (think headers_in, headers_out,
headers_err) and table slot in request_rec, as is access to the
whole connection structure of the request.

but the string and int fields can be read and where appropriate written
to. and there are some methods that wrap the ap_ family.



regards,
  -lukas

PS: it's still not doing too useful things.

PPS: but if you configure your .htaccess appropriately you can use the access
handler.

,-
| error_log('access handler');
| 
| $type = $request-auth_type();
| $name = $request-auth_name();
| $pw = ;
| $s = $request-basic_auth_pw($pw);
| 
| error_log(T $type; N $name; P $pw);
| if ($pw == f0ofoo) return OK;
|
| return AUTH_REQUIRED;
`



Index: sapi/apache/mod_php4.c
===
RCS file: /repository/php4/sapi/apache/mod_php4.c,v
retrieving revision 1.138
diff -u -r1.138 mod_php4.c
--- sapi/apache/mod_php4.c  19 Aug 2002 15:52:21 -  1.138
+++ sapi/apache/mod_php4.c  26 Aug 2002 09:26:53 -
 -34,6 +34,7 
 /* {{{ Prototypes
  */
 int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC);
+int apache_php_module_hook(request_rec *r, char *filename, zval **ret TSRMLS_DC);
 void php_save_umask(void);
 void php_restore_umask(void);
 int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC);
 -45,6 +46,7 
 static int send_parsed_php_source(request_rec * r);
 int php_xbithack_handler(request_rec * r);
 void php_init_handler(server_rec *s, pool *p);
+
 /* }}} */
 
 #if MODULE_MAGIC_NUMBER = 19970728
 -70,6 +72,7 
 module MODULE_VAR_EXPORT php4_module;
 
 int saved_umask;
+//static int setup_env = 0;
 static unsigned char apache_php_initialized;
 
 typedef struct _php_per_dir_entry {
 -296,6 +299,9 
AP(in_request) = 0;
php_request_shutdown(dummy);
}
+if(AP(setup_env)) {
+AP(setup_env) = 0;
+}
 }
 /* }}} */
 
 -649,13 +655,13 
 static void *php_create_dir(pool *p, char *dummy)
 {
HashTable *per_dir_info;
-
per_dir_info = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) 
destroy_per_dir_entry, 1, 0);
register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) 
php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);
 
return per_dir_info;
 }
+
 /* }}} */
 
 /* {{{ php_merge_dir
 -668,6 +674,7 
 }
 /* }}} */
 
+
 /* {{{ php_apache_value_handler_ex
  */
 CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char 
*arg1, char *arg2, int mode)
 -835,6 +842,82 
 }
 /* }}} */
 
+static int php_run_hook(request_rec *r, char *handler)
+{
+   zval *ret = NULL;
+   HashTable *conf;
+
+   TSRMLS_FETCH();
+
+   if (!AP(apache_config_loaded)) {
+   conf = (HashTable *) get_module_config(r-per_dir_config, 
+php4_module);
+   if (conf)
+  zend_hash_apply((HashTable *)conf, (apply_func_t) 
+php_apache_alter_ini_entries TSRMLS_CC);
+   AP(apache_config_loaded) = 1;
+   }
+
+   if (!handler)
+   return DECLINED;
+   
+   hard_timeout(send, r);
+   SG(server_context) = r;
+   php_save_umask();
+   if (!AP(setup_env)) {
+   add_common_vars(r);
+   add_cgi_vars(r);
+   AP(setup_env) = 1;
+   }
+   init_request_info(TSRMLS_C);
+   apache_php_module_hook(r, handler, ret TSRMLS_CC);
+   php_restore_umask();
+   kill_timeout(r);
+   
+   if (ret) {
+   convert_to_long(ret);
+   return Z_LVAL_P(ret);
+   }
+
+   return HTTP_INTERNAL_SERVER_ERROR;
+}
+
+
+static int php_uri_translation(request_rec *r)
+{
+   fprintf(stderr, HOOK: %s\n, __FUNCTION__);
+   return php_run_hook(r, AP(uri_handler));
+}
+
+static int php_auth_hook(request_rec *r)
+{
+   fprintf(stderr, HOOK: %s\n, __FUNCTION__);
+   return php_run_hook(r, AP(auth_handler));
+}
+
+static int php_access_hook(request_rec *r)
+{
+   fprintf(stderr, HOOK: %s\n, __FUNCTION__);
+   return php_run_hook(r, AP(access_handler));
+}
+
+static int php_type_hook(request_rec *r)
+{
+   fprintf(stderr, HOOK: %s\n, __FUNCTION__);
+   return php_run_hook(r, AP(type_handler));
+}
+
+static int php_fixup_hook(request_rec *r)
+{
+   fprintf(stderr, HOOK: %s\n, __FUNCTION__);
+   return php_run_hook(r, AP(fixup_handler));
+}
+
+static int php_logger_hook(request_rec *r)
+{
+   fprintf(stderr, HOOK: %s\n, __FUNCTION__);
+   return php_run_hook(r, AP(logger_handler));
+}
+ 
+
 /* {{{ handler_rec php_handlers[]
  */
 handler_rec php_handlers[] =
 -858,7 +941,7 
 };
 /* }}} */
 
-/* {{{ odule MODULE_VAR_EXPORT php4_module
+/* 

Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread Lukas Schroeder


On Mon, Aug 26, 2002 at 11:18:38AM -0700, Rasmus Lerdorf wrote:
  Well, after 4.3.0 is branched I guess the next release would be
  PHP 5 so it's not that far away. If only Stig would start with the
  branch :) Anyway, I'm more in favor of having this nice hook stuff
  in a seperate branch than with 'magic' things like setting defines.
 
 We can do that, it's just more work to keep it current and as we all know,
 merging branches in CVS just is not a good thing to do.

i offer to do the ugly work.
i put it into the branch for now, so i dont even have to think i tiny
bit about breaking anything. and if time comes, i'll prepare the
necessary patch sets to merge into the php5 branch, without having to
use the dreaded cvs merge branch 'feature'.

would that be a deal?
if so, i'll commit it to apache_hooks today...


regards,
  -lukas



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread Lukas Schroeder

On Mon, Aug 26, 2002 at 02:59:01PM -0400, George Schlossnagle wrote:
 I actually just made a 'new_apache_hooks' branch and am about to commit 
 it all there

argh. so, what now?
i don't like having two branches for this.




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] [RFC] apache_hooks update

2002-08-22 Thread Lukas Schroeder

hi,

attached is a first request for comment for an update to the
apache_hooks code.


a php-handler for uri translation looks like this ($request is of type
ApacheRequest).

?php

  $request-uri('/s.html');
  return DECLINED;
?


a php-handler for uri-to-filename translation would look like this.

?php

  $request-filename('/tmp/foo.html');
  return OK;
?


the patch is intended for peer review only.



regards,
  -lukas



Index: sapi/apache/mod_php4.c
===
RCS file: /repository/php4/sapi/apache/mod_php4.c,v
retrieving revision 1.138
diff -u -r1.138 mod_php4.c
--- sapi/apache/mod_php4.c  19 Aug 2002 15:52:21 -  1.138
+++ sapi/apache/mod_php4.c  22 Aug 2002 11:55:48 -
 -34,6 +34,7 
 /* {{{ Prototypes
  */
 int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC);
+int apache_php_module_hook(request_rec *r, char *filename, zval **ret TSRMLS_DC);
 void php_save_umask(void);
 void php_restore_umask(void);
 int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC);
 -835,6 +836,40 
 }
 /* }}} */
 
+static int php_uri_translation(request_rec *r)
+{
+   char *handler = NULL;
+   zval *ret = NULL;
+   HashTable *conf;
+   TSRMLS_FETCH();
+
+   if (!AP(apache_config_loaded)) {
+   conf = (HashTable *) get_module_config(r-per_dir_config, 
+php4_module);
+   if (conf)
+   zend_hash_apply((HashTable *)conf, (apply_func_t) 
+php_apache_alter_ini_entries TSRMLS_CC);
+   AP(apache_config_loaded) = 1;
+   }
+
+   handler = AP(uri_handler);
+
+   if (!handler)
+   return DECLINED;
+
+   hard_timeout(send, r);
+   SG(server_context) = r;
+   php_save_umask();
+   add_common_vars(r);
+   add_cgi_vars(r);
+   init_request_info(TSRMLS_C);
+   apache_php_module_hook(r, handler, ret TSRMLS_CC);
+   php_restore_umask();
+   kill_timeout(r);
+
+   convert_to_long(ret);
+   fprintf(stderr, %s() %d\n, __FUNCTION__, Z_LVAL_P(ret));
+   return Z_LVAL_P(ret);
+}
+
 /* {{{ handler_rec php_handlers[]
  */
 handler_rec php_handlers[] =
 -870,7 +905,7 
NULL,   /* merge server config */
php_commands,   /* command table */
php_handlers,   /* handlers */
-   NULL,   /* filename translation */
+   php_uri_translation,/* filename translation */
NULL,   /* check_user_id */
NULL,   /* check auth */
NULL,   /* check access */
Index: sapi/apache/mod_php4.h
===
RCS file: /repository/php4/sapi/apache/mod_php4.h,v
retrieving revision 1.17
diff -u -r1.17 mod_php4.h
--- sapi/apache/mod_php4.h  28 Feb 2002 08:27:19 -  1.17
+++ sapi/apache/mod_php4.h  22 Aug 2002 11:55:48 -
 -32,6 +32,8 
long xbithack;
long terminate_child;
zend_bool in_request;
+   zend_bool apache_config_loaded;
+   char *uri_handler;
 } php_apache_info_struct;
 
 extern zend_module_entry apache_module_entry;
Index: sapi/apache/php_apache.c
===
RCS file: /repository/php4/sapi/apache/php_apache.c,v
retrieving revision 1.66
diff -u -r1.66 php_apache.c
--- sapi/apache/php_apache.c13 Aug 2002 04:03:20 -  1.66
+++ sapi/apache/php_apache.c22 Aug 2002 11:55:48 -
 -37,6 +37,11 
 #define SECTION(name)  PUTS(H2 align=\center\ name /H2\n)
 
 extern module *top_module;
+static int le_apachereq;
+static zend_class_entry *apacherequest_class_entry;
+
+#define SLOT_URI 0
+#define SLOT_FILENAME 1
 
 PHP_FUNCTION(virtual);
 PHP_FUNCTION(apache_request_headers);
 -49,6 +54,7 
 
 PHP_MINFO_FUNCTION(apache);
 
+
 function_entry apache_functions[] = {
PHP_FE(virtual,
 NULL)
PHP_FE(apache_request_headers,  NULL)
 -61,15 +67,17 
{NULL, NULL, NULL}
 };
 
-
+/* {{{ php_apache ini entries
+ */
 PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(xbithack,   0,   
 PHP_INI_ALL,OnUpdateInt,xbithack, php_apache_info_struct, 
php_apache_info)
STD_PHP_INI_ENTRY(engine, 1,   
 PHP_INI_ALL,OnUpdateInt,engine, 
php_apache_info_struct, php_apache_info)
STD_PHP_INI_ENTRY(last_modified,  0,   
 PHP_INI_ALL,OnUpdateInt,last_modified, 
php_apache_info_struct, php_apache_info)
STD_PHP_INI_ENTRY(child_terminate,0,

Re: [PHP-DEV] [RFC] apache_hooks update

2002-08-22 Thread Lukas Schroeder

On Thu, Aug 22, 2002 at 08:07:33AM -0700, Rasmus Lerdorf wrote:
 Does it work?
 

hehe. yes it does.


besides the fact, that a lot of functionality is still missing, the only
issue currently is an incomplete cleanup:
./Zend/zend_execute.c(1704) :  Freeing 0x0828FFCC (12 bytes), script=-
./sapi/apache/php_apache.c(143) : Freeing 0x0828FCA4 (12 bytes), script=-



-lukas
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] libxml bundling

2002-06-02 Thread Lukas Schroeder

On Sat, Jun 01, 2002 at 04:21:33PM -0400, Dan Kalowsky wrote:
 When I state that things shouldn't be enabled by default, it is not
 towards making it harder for beginners.  I would much rather see PHP
 using
 something like:

 ./configure --basic
 or
 ./configure --standard
 or some variation along that theme.


On Sun, Jun 02, 2002 at 12:25:17AM +0300, Zeev Suraski wrote:
 Why not have a  --bare (or equivalent) switch of that kind, to disable 
 literally EVERYTHING that's not mandatory?  I believe the issue is that for 


instead of modifying ./configure to allow grouping a set of --with{out}
--{en|dis}able into one option (--basic, --bare, ...) i propose setting
up brothers of ./config.nice like

./config.bare
./config.basic
./config.standard
./config.everything

it'd be obvious _what_ these scripts enable, and you could easily use
them as a template to modify these things to get everything minus odbc
or bare + pdf.




-lukas


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] bundling libxml2 / bundling locations

2002-05-30 Thread Lukas Schroeder

On Wed, May 29, 2002 at 10:53:38AM -0700, brad lafountain wrote:
  It was mentioned before about bundling libxml2 with php with expat or instead
 of expat. Where do we stand with this? I emailed the developer asking
 permission to bundle it if we choose to do it (no response yet).


for the record, -1 from me on bundling libxml2 with php.
imho, the disadvantages outweigh the benefits by far.



-lukas
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] status of apache_hooks?

2002-05-23 Thread Lukas Schroeder

hi!

is there anyone actively working on the apache_hooks code?


regards,
  -lukas


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] status of apache_hooks?

2002-05-23 Thread Lukas Schroeder

On Thu, May 23, 2002 at 07:53:27AM -0700, Rasmus Lerdorf wrote:
  is there anyone actively working on the apache_hooks code?
 
 Nobody showed any interest in it so I put it on the back burner for a
 while.

ok, well i'm very interested, and willing to do the coding, too.

months ago i submitted the little brother[1] of apache_hooks and used
it since. but apache_hooks would give me more power by far and i'm eager
to use it.



-lukas


[1] http://marc.theaimsgroup.com/?l=php-devm=101356858710191w=2
subject was: [patch] one script to handle them all
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] domxml questions

2002-05-18 Thread Lukas Schroeder

On Sat, May 18, 2002 at 10:05:32AM -0400, Rob Richards wrote:
 I have been going through the latest domxml extension and have a few
 questions about it.  Looking at the docs, it is indicated that
 set_content and get_content are depreciated.
 
 set_content - Create a new node with e.g. DomDocument_create_text_node() und
  add it with DomNode_append_child().
 get_content - Content is just a text node and can be accessed with
  DomNode_child_nodes().
 
 Would get_content really be replace with node_value? All the child_nodes
 would give you is the child nodes.

the contents of an element-node are contained in a child-node of that
element-node with the special node-name #text. using child_nodes would
give you these contents. but, without a get_content() (get_node_value())
function there is no way to get the nodeValue (content) of the #text
node. hehe.

i hope, that deprecating or even removing a get_content() function (or
an equivalent) wont happen, because i definately dont want to replace
entity-references in contents manually.
the purpose of get_content() was and is to do that for me.


 On that note, if you are trying to set the value of an existing node, using
 the replacement (as indicated from the docs) you would should be creating a
 new node and appending it, which means you then should remove the old node.
 Shouldnt there be a set_node_value or similar function to just replace the
 content of an existing node? A set_node_value function would be DOM
 compliant as the nodeValue property is read/write according to the specs.

heh, that is what set_content() is (was? i hope not) for.



regards,
  -lukas
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] php 4.2.0 ./. really weird mozilla file upload problem featuring segfault

2002-04-22 Thread Lukas Schroeder

hi list,

first, to narrow down the list of systems affected:
it only happens with the one .jpg file and only if you try to upload the
file in a special html-form and only with mozilla 0.9.9.
i didnt test another mozilla; i did test with netscape 4.76
successfully.

i was supposed to just add a file upload to an html form to allow users
to upload some images. for testing i had to randomly pick a file. out of
all files on my disks, i chose exactly the one that would result in
mozilla just stalling the request and make php segfault as soon as i hit
ESC!  it's been a great evening since...

using the same browser but different files  :   works
intercepting the segfault-provoking-request
bytestream and netcat'ing it into the webserver :   works
using a simple (minimalistic) file upload form  :   works

oh and yes, i can reproduce this bug at a rate of 100% when the
preconditions are met...

i believe that mozilla is faulty in this case. but php shouldn't segfault.
i have not tested all variations to find out what exactly mozilla is so
confused about here. the mozilla guys might want to check this...
i dont know. all too strange. if anyone has any idea what's causing
this, let me know...

here's my simple patch[1]. it doesn't make the file upload work, but at
least php does not segfault anymore (see backtrace[1]) and gracefully
terminates the request.

--- php-4.2.0/main/rfc1867.cTue Apr  2 01:29:19 2002
+++ php-4.2.0RC4/main/rfc1867.c Mon Apr 22 23:54:06 2002
 -371,11 +371,12 
}

entry = zend_llist_get_first(header);
-   do {
+   while (entry) {
if (!strcasecmp(entry-key, key)) {
return entry-value;
}
-   } while ((entry = zend_llist_get_next(header)));
+   entry = zend_llist_get_next(header);
+   }

return NULL;
 }


some more info so someone might get on the right track here:
  - the content-length header is set correctly, i.e. apache isn't
waiting for data mozilla wont send
  - the uploaded file is __fully__ retrieved! and md5sum yields the same
result. (i manually found the tmp/php* corresponding to that upload).
  - the php code for the POST'ed to url is __never__ executed even
though the upload seems to be complete. and apache does not add it
to the access log (not after i hit ESC either).


[1] relevant files -- the problematic image, the patch, the backtrace,
the bytestream -- can be found here http://www.azzit.de/patches/php4/fileupload-segv/



regards,
  -lukas


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] domxml nightmare and suggestion

2002-04-13 Thread Lukas Schroeder

On Sat, Apr 13, 2002 at 12:41:44PM +0200, Christian Stocker wrote:
 top issues... Personally I don't have much problems with this extension,
 but missing docu and the API as a moving target, is something which
 worries a lot of people. But one of the weakest things about domxml is
 IMHO that it promises a DOM-API, which it does not provide very
 consitently and a lot of functionality is still missing.
 
 With all this points, i'd like to start a discussion about starting from
 scratch with the DOM-API in PHP. Maybe creating a new extension to avoid
 problems with all the people using domxml already (and therefore not
 relying on keeping the old API).

 Ideas, thoughts, etc?

i'd rather see an effort of finally getting domxml itself into a mature
state.  it's about time, imho.
regarding the api, it's not that people could/should have relied upon a
stable domxml api. it's _still_ experimental and marked as such. i'm
running a patched[1] version of domxml for quite some time for
development to get the functionality i need(ed), too.

let's whip this beast into shape.


[1] for patches see http://www.azzit.de/patches/php4/


regards,
  -lukas
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] [patch] domxml ./. fix for some memory leaks + cleanups

2002-04-04 Thread Lukas Schroeder

hi!

this patch is against current cvs. it contains some trivial cleanups
and fixes for several memory leaks, where memory that gets malloc()ed in
libxml2 is not free()d. please apply...


additionally, this patch changes get_attribute() to return
FALSE instead of an empty string if the attribute does not exists.
without this change, php code cannot distinguish between a missing and
an empty attribute. i hope this gets applied too...


regards,
  -lukas



Index: ext/domxml/php_domxml.c
===
RCS file: /repository/php4/ext/domxml/php_domxml.c,v
retrieving revision 1.132
diff -u -r1.132 php_domxml.c
--- ext/domxml/php_domxml.c 27 Mar 2002 21:45:45 -  1.132
+++ ext/domxml/php_domxml.c 4 Apr 2002 10:28:29 -
 -744,9 +744,7 
 {
zval *wrapper;
 
-   if (! found) {
*found = 0;
-   }
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);
 -851,9 +849,7 
zval *wrapper;
int rsrc_type;
 
-   if (! found) {
*found = 0;
-   }
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);
 -937,9 +933,7 
char *content;
int rsrc_type;
 
-   if (! found) {
*found = 0;
-   }
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);
 -976,6 +970,7 
if (content) {
add_property_long(wrapper, type, Z_TYPE_P(nodep));
add_property_stringl(wrapper, content, (char *) 
content, strlen(content), 1);
+   xmlFree(content);
}
break;
}
 -989,6 +984,7 
if (content) {
add_property_long(wrapper, type, Z_TYPE_P(nodep));
add_property_stringl(wrapper, content, (char *) 
content, strlen(content), 1);
+   xmlFree(content);
}
break;
}
 -1000,8 +996,10 
rsrc_type = le_domxmlpip;
content = xmlNodeGetContent(nodep);
add_property_stringl(wrapper, target, (char *) nodep-name, 
strlen(nodep-name), 1);
-   if (content)
+   if (content) {
add_property_stringl(wrapper, data, (char *) 
content, strlen(content), 1);
+   xmlFree(content);
+   }
break;
}
 
 -1024,8 +1022,10 
add_property_stringl(wrapper, name, (char *) nodep-name, 
strlen(nodep-name), 1);
if (Z_TYPE_P(obj) == XML_ENTITY_REF_NODE) {
content = xmlNodeGetContent(nodep);
-   if (content)
+   if (content) {
add_property_stringl(wrapper, content, (char 
*) content, strlen(content), 1);
+   xmlFree(content);
+   }
}
break;
}
 -1038,8 +1038,10 
add_property_stringl(wrapper, name, (char *) attrp-name, 
strlen(attrp-name), 1);
add_property_long(wrapper, type, Z_TYPE_P(attrp));
content = xmlNodeGetContent((xmlNodePtr) attrp);
-   if (content)
+   if (content) {
add_property_stringl(wrapper, value, (char *) 
content, strlen(content), 1);
+   xmlFree(content);
+   }
break;
}
 
 -1093,8 +1095,10 
rsrc_type = le_domxmlcdatap;
content = xmlNodeGetContent(nodep);
add_property_long(wrapper, type, Z_TYPE_P(nodep));
-   if (content)
+   if (content) {
add_property_stringl(wrapper, content, (char *) 
content, strlen(content), 1);
+   xmlFree(content);
+   }
break;
}
 
 -1749,7 +1753,7 
 }
 /* }}} */
 
-/* {{{ proto object domxml_node_prefix(void)
+/* {{{ proto string domxml_node_prefix(void)
Returns namespace prefix of node */
 PHP_FUNCTION(domxml_node_prefix)
 {
 -2103,7 +2107,8 
RETURN_FALSE;
}

-   RETURN_STRING(mem,1);
+   RETVAL_STRING(mem,1);
+   xmlFree(mem);
 }
 /* }}} */
 
 -2201,9 +2206,10 
 
value = xmlGetProp(nodep, name);
if (!value) {
-   RETURN_EMPTY_STRING();
+   RETURN_FALSE;
} else {
-   RETURN_STRING(value, 1);
+   

[PHP-DEV] [patch] ming ./. trivial fix for streams error

2002-03-19 Thread Lukas Schroeder

hi!

during the streams changes a tiny error was introduced checking the
return code of php_stream_cast the wrong way around...

this patch against latest CVS fixes it.
someone with enough karma, please apply.



regards,
  -lukas



Index: ext/ming/ming.c
===
RCS file: /repository/php4/ext/ming/ming.c,v
retrieving revision 1.32
diff -u -r1.32 ming.c
--- ext/ming/ming.c 17 Mar 2002 22:50:55 -  1.32
+++ ext/ming/ming.c 19 Mar 2002 20:31:38 -
 -209,7 +209,7 
 
   what =  zend_fetch_resource(zfile TSRMLS_CC, -1, File-Handle, type, 1, 
php_file_le_stream());
 
-  if (!php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO, (void*)file, 
REPORT_ERRORS))   {
+  if (php_stream_cast((php_stream*)what, PHP_STREAM_AS_STDIO, (void*)file, 
+REPORT_ERRORS) != SUCCESS) {
return NULL;
   }
   



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] [patch] domxml ./. trivial cleanup

2002-03-07 Thread Lukas Schroeder

hi!

the patch below is against cvs as of several minutes ago...

doing
   if (! found)
   *found = ...;

i did not change it into if (found) either, b/c found is a
non-optional parameter of internally used functions; it will not be
NULL ever.



regards,
  -lukas

PS: is there currently a maintainer of the domxml code who should be CC'd ?



Index: php_domxml.c
===
RCS file: /repository/php4/ext/domxml/php_domxml.c,v
retrieving revision 1.119
diff -u -r1.119 php_domxml.c
--- php_domxml.c7 Mar 2002 16:34:13 -   1.119
+++ php_domxml.c7 Mar 2002 20:29:09 -
 -718,9 +718,7 
 {
zval *wrapper;
 
-   if (! found) {
-   *found = 0;
-   }
+   *found = 0;
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);
 -825,9 +823,7 
zval *wrapper;
int rsrc_type;
 
-   if (! found) {
-   *found = 0;
-   }
+   *found = 0;
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);
 -911,9 +907,7 
char *content;
int rsrc_type;
 
-   if (! found) {
-   *found = 0;
-   }
+   *found = 0;
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);
 -3355,9 +3349,7 
zval *wrapper;
int rsrc_type;
 
-   if (! found) {
-   *found = 0;
-   }
+   *found = 0;
 
if (!obj) {
MAKE_STD_ZVAL(wrapper);



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] [patch] domxml ./. resubmitting fix for bug #14522

2002-03-07 Thread Lukas Schroeder


Bug #14522  Crash with using $node-unlink();

Bug #14522 was prematurely marked as closed; i submitted this patch, but
the bug was marked as closed, before the patch really got a applied to
CVS to fix it...




regards,
  -lukas


Index: php_domxml.c
===
RCS file: /repository/php4/ext/domxml/php_domxml.c,v
retrieving revision 1.119
diff -u -r1.119 php_domxml.c
--- php_domxml.c7 Mar 2002 16:34:13 -   1.119
+++ php_domxml.c7 Mar 2002 22:17:49 -
 -1802,8 +1802,6 
DOMXML_PARAM_NONE(nodep, id, le_domxmlnodep);
 
xmlUnlinkNode(nodep);
-   xmlFreeNode(nodep);
-   zval_dtor(id);  /* This is not enough because the 
children won't be deleted */
 }
 /* }}} */
 

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [patch] one script to handle them all

2002-02-13 Thread Lukas Schroeder

On Wed, Feb 13, 2002 at 08:13:42AM +0100, Markus Fischer wrote:
 Patches should always be against latest CVS.

here it is. against latest CVS.



regards,
  -lukas
 


Index: sapi/apache/mod_php4.c
===
RCS file: /repository/php4/sapi/apache/mod_php4.c,v
retrieving revision 1.127
diff -u -r1.127 mod_php4.c
--- sapi/apache/mod_php4.c  11 Dec 2001 15:31:53 -  1.127
+++ sapi/apache/mod_php4.c  13 Feb 2002 11:20:58 -
@@ -483,6 +483,39 @@
 }
 /* }}} */
 
+/* {{{ php_get_request_handler
+ */
+static int php_get_request_handler(request_rec *r, char **target)
+{
+   HashTable *per_dir_conf;
+   php_per_dir_entry *per_dir_entry;
+   char *filename;
+
+   if (!(per_dir_conf = get_module_config(r-per_dir_config, php4_module)))
+   return 0;
+
+   if (zend_hash_find(per_dir_conf, request_handler, 
+sizeof(request_handler)-1,
+   (void **)per_dir_entry) == SUCCESS) {
+
+   if (!ap_os_is_path_absolute(per_dir_entry-value)) {
+   char *dirnam = ap_pstrdup(r-pool, r-filename);
+   char *x = strrchr(dirnam, '/');
+
+   if (x != NULL)
+   *x = 0;
+   filename = ap_make_full_path(r-pool, dirnam, 
+per_dir_entry-value);
+   }
+   else
+   filename = ap_pstrdup(r-pool, per_dir_entry-value);
+
+   *target = filename;
+   return 1;
+   }
+
+   return 0;
+}
+/* }}} */
+
 /* {{{ send_php
  */
 static int send_php(request_rec *r, int display_source_mode, char *filename)
@@ -502,6 +535,9 @@
return OK;
}
 
+   if (php_get_request_handler(r, filename))
+   r-filename = filename;
+
zend_first_try {
/* We don't accept OPTIONS requests, but take everything else */
if (r-method_number == M_OPTIONS) {
@@ -846,6 +882,26 @@
 }
 /* }}} */
 
+/* {{{ php_type_checker
+ */
+static int php_type_checker(request_rec *r)
+{
+   char *filename;
+   
+   /* if a request_handler has been registered, the type checker tells 
+* apache to invoke our send_php handler; otherwise we deny responsibility
+* for this request
+*/
+   
+   if (php_get_request_handler(r, filename)) {
+   r-handler = application/x-httpd-php;
+   return OK;
+   }
+   
+   return DECLINED;
+}
+/* }}} */
+
 /* {{{ handler_rec php_handlers[]
  */
 handler_rec php_handlers[] =
@@ -885,7 +941,7 @@
NULL,   /* check_user_id */
NULL,   /* check auth */
NULL,   /* check access */
-   NULL,   /* type_checker */
+   php_type_checker,   /* type_checker */
NULL,   /* fixups */
NULL/* logger */
 #if MODULE_MAGIC_NUMBER = 19970103



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] [patch] one script to handle them all

2002-02-12 Thread Lukas Schroeder

Hi,

(resubmitting. i submitted this on Jan 12 before, but did not get any
response.)

this is a 'request_handler'-support patch for php. it applies to
php-4.1.1. it only covers sapi/apache/...
diffstat says
mod_php4.c |   58 +-
1 files changed, 57 insertions(+), 1 deletion(-)


with this patch applied you can use the following to register a
request_handler:
  php_value request_handler /www/foo.php

every request going to a virtualhost / directory / location that a
request_handler is registered for will be passed to that /www/foo.php
script


the attached patch can also be downloaded from
http://www.azzit.de/patches/php4/
[it's the *request_handler* file there. duh. ;-)]


Comments, bug reports, suggestions are welcome,

regards,
  -lukas



--- php-4.1.1/sapi/apache/mod_php4.c.orig   Tue Feb 12 00:05:35 2002
+++ php-4.1.1/sapi/apache/mod_php4.cWed Feb 13 02:57:13 2002
@@ -483,6 +483,39 @@
 }
 /* }}} */
 
+/* {{{ php_get_request_handler
+ */
+static int php_get_request_handler(request_rec *r, char **target)
+{
+   HashTable *per_dir_conf;
+   php_per_dir_entry *per_dir_entry;
+   char *filename;
+
+   if (!(per_dir_conf = get_module_config(r-per_dir_config, php4_module)))
+   return 0;
+
+   if (zend_hash_find(per_dir_conf, request_handler, 
+sizeof(request_handler)-1,
+   (void **)per_dir_entry) == SUCCESS) {
+
+   if (!ap_os_is_path_absolute(per_dir_entry-value)) {
+   char *dirnam = ap_pstrdup(r-pool, r-filename);
+   char *x = strrchr(dirnam, '/');
+
+   if (x != NULL)
+   *x = 0;
+   filename = ap_make_full_path(r-pool, dirnam, 
+per_dir_entry-value);
+   }
+   else
+   filename = ap_pstrdup(r-pool, per_dir_entry-value);
+
+   *target = filename;
+   return 1;
+   }
+
+   return 0;
+}
+/* }}} */
+
 /* {{{ send_php
  */
 static int send_php(request_rec *r, int display_source_mode, char *filename)
@@ -502,6 +535,9 @@
return OK;
}
 
+   if (php_get_request_handler(r, filename))
+   r-filename = filename;
+
zend_first_try {
/* We don't accept OPTIONS requests, but take everything else */
if (r-method_number == M_OPTIONS) {
@@ -846,6 +882,26 @@
 }
 /* }}} */
 
+/* {{{ php_type_checker
+ */
+static int php_type_checker(request_rec *r)
+{
+   char *filename;
+
+   /* if a request_handler has been registered, the type checker tells 
+* apache to invoke our send_php handler; otherwise we deny responsibility
+* for this request
+*/
+
+   if (php_get_request_handler(r, filename)) {
+   r-handler = application/x-httpd-php;
+   return OK;
+   }
+
+   return DECLINED;
+}
+/* }}} */
+
 /* {{{ handler_rec php_handlers[]
  */
 handler_rec php_handlers[] =
@@ -885,7 +941,7 @@
NULL,   /* check_user_id */
NULL,   /* check auth */
NULL,   /* check access */
-   NULL,   /* type_checker */
+   php_type_checker,   /* type_checker */
NULL,   /* fixups */
NULL/* logger */
 #if MODULE_MAGIC_NUMBER = 19970103



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] [patch] (sapi/apache) global,default request_handler

2002-01-11 Thread Lukas Schroeder

Hi all,

this is a 'request_handler'-support patch for php. it applies to php-4.1.1
and it only covers sapi/apache/...
with this patch applied you can use the following to register a
request_handler 

  php_value request_handler /www/foo.php

every request going to a virtualhost / directory / location that a
request_handler is registered for will be passed to your /www/foo.php
script 

AFAIC, it's currently quite limited OS wise. if it works under e.g.
windows at all, one has to specify an absolute path to the
request_handler-file, at least...


the patch below can also be downloaded from
http://www.azzit.de/patches/php-4.1.1-request_handler-20020111.diff


Comments, bug reports, suggestions are welcome,

regards,
  -lukas


--- sapi/apache/mod_php4.c.orig Sun Sep 16 17:49:55 2001
+++ sapi/apache/mod_php4.c  Sat Jan 12 00:12:09 2002
@@ -483,6 +483,40 @@
 }
 /* }}} */
 
+/* {{{ php_get_request_handler
+ */
+static int php_get_request_handler(request_rec *r, char **target)
+{
+   HashTable *per_dir_conf;
+   php_per_dir_entry *per_dir_entry;
+   char *filename;
+
+   if (!(per_dir_conf = get_module_config(r-per_dir_config, php4_module)))
+   return 0;
+
+   if (zend_hash_find(per_dir_conf, request_handler, 
+sizeof(request_handler)-1,
+   (void **)per_dir_entry) == SUCCESS)
+   {
+   if (!ap_os_is_path_absolute(per_dir_entry-value))
+   {
+   char *dirnam = ap_pstrdup(r-pool, r-filename);
+   char *x = strrchr(dirnam, '/');
+
+   if (x != NULL)
+   *x = 0;
+   filename = ap_make_full_path(r-pool, dirnam, 
+per_dir_entry-value);
+   }
+   else
+   filename = ap_pstrdup(r-pool, per_dir_entry-value);
+
+   *target = filename;
+   return 1;
+   }
+
+   return 0;
+}
+/* }}} */
+
 /* {{{ send_php
  */
 static int send_php(request_rec *r, int display_source_mode, char *filename)
@@ -502,6 +536,9 @@
return OK;
}
 
+   if (php_get_request_handler(r, filename))
+   r-filename = filename;
+
zend_first_try {
/* We don't accept OPTIONS requests, but take everything else */
if (r-method_number == M_OPTIONS) {
@@ -846,6 +883,26 @@
 }
 /* }}} */
 
+/* {{{ php_type_checker
+ */
+static int php_type_checker(request_rec *r)
+{
+   char *filename;
+
+   /* if a request_handler has been registered, the type checker tells 
+* apache to invoke our send_php handler; otherwise we deny responsibility
+* for this request
+*/
+
+   if (php_get_request_handler(r, filename)) {
+   r-handler = application/x-httpd-php;
+   return OK;
+   }
+
+   return DECLINED;
+}
+/* }}} */
+
 /* {{{ handler_rec php_handlers[]
  */
 handler_rec php_handlers[] =
@@ -885,7 +942,7 @@
NULL,   /* check_user_id */
NULL,   /* check auth */
NULL,   /* check access */
-   NULL,   /* type_checker */
+   php_type_checker,   /* type_checker */
NULL,   /* fixups */
NULL/* logger */
 #if MODULE_MAGIC_NUMBER = 19970103




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] PHP and WebDAV

2001-07-25 Thread Lukas Schroeder


On Wed, Jul 25, 2001 at 05:53:43AM +0100, Christoph Steinmann wrote:

 Are there any concrete plans to integrate functions or classes to access
 external WebDAV ressources? WebDAV seems to be used more and more to upload
 data, in replacement of FTP. It would be cool to have some functions to read
 and write files and directories over WebDAV.
 
 I don't know wheter WebDAV functions should be in a php extension (like file
 system and FTP) or in a PEAR class (HTTP). [EMAIL PROTECTED]
 has opened a project called phpdav on Sourceforge some months ago, but the
 files are not yet published.


Hello list(s),

some weeks ago i quickly wrote a simple php WebDAV module.  The module
does everything i need(ed), and i'll probably not invest too much time
in the next weeks / months.  Maybe someone is interested and wants to
take a look at it.

The download is available from http://www.azzit.de/phpwebdav/
The documentation can be found in the README file at that URL and in the
tarball.

I only tested / used it as a shared object/module under linux with
apache and PHP 404pl1, 405 and 406.


An example:

to list the files / collection in the dav-server's root:

?
header(Content-type: text/plain);
$c = phpwebdav_connect(http://dav.local/;); // my local WebDAV-Server
print_r(phpwebdav_list($c, /));
?



regards,
  lukas


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]