Re: [PHP-DEV] Problems with LSB

2008-02-11 Thread Moritz Bechler
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

My original reply missed the list :|

Hi,


 i've written the following code using Etiennes LSB. But I'm facing some
 problems.

 ?php
 class A {
 function foo() {
 echo get_called_class();
 }
 }

 class B extends A {
 }

 class C {
 function moo() {
 B::foo();
 }
 }

 B::foo();   // echos B - good

 $c = new C;
 $c-moo();  // echos C - wtf?? should be B
 ?

 Is it a bug, or did I miss anything?


If you mark your function foo static - as you should - its BB for me.

Moritz Bechler



-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHsEeydLVsKnwBr9YRAu8LAJ4+/pnKZ1YzM0wN9k7Vg9eyWaZnUQCeKTrO
hgv4dRz1YtLqHRgagUOKwQA=
=cxLj
-END PGP SIGNATURE-

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



Re: [PHP-DEV] question regarding type hinting parameters of php functions (array_slice)

2007-11-28 Thread Moritz Bechler
Hi,
 
 When calling
 array_slice($array, 0, (float)2);
 the resulting array is EMPTY.
 When using the right type
 array_slice($array, 0, (int)2);
 it works as expected.
 
 i think this should print a warning like other array functions.
 But i looked into the src and this looks more like a casting bug inside this
 function.

Actually most functions use implicit type conversions for this. So I
wouldn't say this should cause a warning.

 
 
 So i think the float value isnt correct casted as int value here. Maybe
 someone else
 can proof this.

Yes, you are right here I think

the code is

if (ZEND_NUM_ARGS() = 3  Z_TYPE_P(length_param) != IS_NULL) {
length = Z_LVAL_P(length_param);
} else {
length = num_in;
}

and afaik should be

if (ZEND_NUM_ARGS() = 3  Z_TYPE_P(length_param) != IS_NULL) {
convert_to_long(length_param);
length = Z_LVAL_P(length_param);
} else {
length = num_in;
}


best regards

Moritz Bechler

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



Re: [PHP-DEV] Re: namespaces: import name conflicts with defined class

2007-10-03 Thread Moritz Bechler
Hi internals,

I think you are conentrating on the Exception (and even internal class)
examples a bit too much. Take the following example:


a.php:
?php

// 1. Some library which does not use namespaces and defines a class Foo
include(b.php);
// 2. Some part of a library using namespaces
include(c.php);
// 3. Some other part of the namespace-using library
include(d.php);
?

b.php:
?php
class Foo {
}
?

c.php:
?php
namespace Bar;

class Foo {
}
?

d.php:
?php
namespace Bar::Other;
import Bar::Foo;
?


Running this example produces a Fatal error: Import name 'Foo'
conflicts with defined class in [...]/d.php on line 4. This problem
does not only exist with internal classes (which is bad enough - still
remember DateTime?) but also when some non-namespaced code might be used
  in conjunction.

As using namespaces is about preventing naming collisions having to
assume that some class Foo does not exist while developing the library
using namespaces is just inacceptable and makes the namespace
implementation pretty useless.
And if you start arguing that you should not use import in cases where
you don't control the global scope you could pretty much argue not to
use it at all and remove it (which makes namespaces some eye-candy for
very long class names).

best regards

Moritz Bechler

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



Re: [PHP-DEV] Just checking something before posting a bug report

2007-09-26 Thread Moritz Bechler
Hi,

I can confirm that behaviour (older CVS build) and it seems that you can
get that thingy to segfault if you var_dump twice. That might be helpful
for investigating that interesting behaviour. Backtrace follows...


#0  0x0087a3b9 in zend_mm_check_ptr (heap=0xe20710,
ptr=0x7fffa5cd22c8, silent=0x1, __zend_filename=0xbf3e40
/usr/src/php5/Zend/zend_variables.c, __zend_lineno=0xaf,
__zend_orig_filename=0xbf2830 /usr/src/php5/Zend/zend_execute.h,
__zend_orig_lineno=0x46) at /usr/src/php5/Zend/zend_alloc.c:1264
#1  0x0087bdc8 in _zend_mm_free_int (heap=0xe20710,
p=0x7fffa5cd22c8, __zend_filename=0xbf3e40
/usr/src/php5/Zend/zend_variables.c, __zend_lineno=0xaf,
__zend_orig_filename=0xbf2830 /usr/src/php5/Zend/zend_execute.h,
__zend_orig_lineno=0x46) at /usr/src/php5/Zend/zend_alloc.c:1895
#2  0x0087d4b5 in _efree (ptr=0x7fffa5cd22c8,
__zend_filename=0xbf3e40 /usr/src/php5/Zend/zend_variables.c,
__zend_lineno=0xaf, __zend_orig_filename=0xbf2830
/usr/src/php5/Zend/zend_execute.h, __zend_orig_lineno=0x46) at
/usr/src/php5/Zend/zend_alloc.c:2263
#3  0x0088c248 in safe_free_zval_ptr_rel (p=0x7fffa5cd22c8,
__zend_filename=0xbf3e40 /usr/src/php5/Zend/zend_variables.c,
__zend_lineno=0xaf, __zend_orig_filename=0xbf2798
/usr/src/php5/Zend/zend_execute_API.c, __zend_orig_lineno=0x19f) at
zend_execute.h:70
#4  0x0088c1cd in _zval_ptr_dtor (zval_ptr=0x10d04d0,
__zend_filename=0xbf3e40 /usr/src/php5/Zend/zend_variables.c,
__zend_lineno=0xaf) at /usr/src/php5/Zend/zend_execute_API.c:415
#5  0x0089b0e1 in _zval_ptr_dtor_wrapper (zval_ptr=0x10d04d0) at
/usr/src/php5/Zend/zend_variables.c:175
#6  0x008aa9fa in zend_hash_destroy (ht=0x10cfed8) at
/usr/src/php5/Zend/zend_hash.c:526
#7  0x00891865 in destroy_zend_class (pce=0x10f9cb8) at
/usr/src/php5/Zend/zend_opcode.c:182
#8  0x008aada8 in zend_hash_apply_deleter (ht=0xe21040,
p=0x10f9ca0) at /usr/src/php5/Zend/zend_hash.c:611
#9  0x008ab3de in zend_hash_reverse_apply (ht=0xe21040,
apply_func=0x88b75b clean_non_persistent_class) at
/usr/src/php5/Zend/zend_hash.c:760
#10 0x0088be10 in shutdown_executor () at
/usr/src/php5/Zend/zend_execute_API.c:291
#11 0x0089c755 in zend_deactivate () at
/usr/src/php5/Zend/zend.c:860
#12 0x00843392 in php_request_shutdown (dummy=0x0) at
/usr/src/php5/main/main.c:1463
#13 0x009206de in main (argc=0x2, argv=0x7fffa5cd4cd8) at
/usr/src/php5/sapi/cli/php_cli.c:1332



best regards

Moritz Bechler

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



Re: [PHP-DEV] RE: Ext/OpenSSL patch

2007-09-23 Thread Moritz Bechler
Hi Pierre,


 By the way, it would be nice (and faster) if you can join a couple of
 tests and examples (with required data). it will make my work a bit
 easier while testing your patch.

It took some time - but I now managed to put together some test cases
(which hopefully can also serve as examples). I noticed that the current
openssl_x509_checkpurpose function does not allow for passing
verification flags so I introduced a new function openssl_x509_check
(verify might be better but might cause confusion with openssl_verify)
which does pretty much the same thing but takes a flags parameter which
can be used to enable CRL checking and some other checking features
which I did not test yet. I chose to add a new function because a)
adding the argument to the end forces passing two (one unused in most
cases) optional arguments b) _checkpurpose is a bit too specific. I hope
that approach is okay.

The updated patch is at
http://mbechler.eenterphace.org/php6-openssl-crl.patch
and the phpt and required data (needs a small CA, included files are
valid for 5 years) at
http://mbechler.eenterphace.org/php6-openssl-crl-tests.tar.bz2


I noted my test fails (even for ascii filenames) when run in unicode
mode which is a result of
this check in php_openssl_x509_from_zval:

if (!(Z_TYPE_PP(val) == IS_STRING || Z_TYPE_PP(val) == IS_OBJECT)) {
return NULL;
}

maybe I'll find some time to have a look at proper filesystem encoding
conversions for ext/openssl.

best regards

Moritz Bechler

PS: Is there any way to recover/reset a lost bug password so I can add
these links to my feature request?

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



Re: [PHP-DEV] RE: Ext/OpenSSL patch

2007-08-03 Thread Moritz Bechler
Pierre wrote:
 Hi Dmitry,
 
 On 8/3/07, Dmitry Stogov [EMAIL PROTECTED] wrote:

 -Original Message-
 From: Jani Taskinen [mailto:[EMAIL PROTECTED]
 Sent: Friday, August 03, 2007 2:13 PM
 To: Dmitry Stogov
 Cc: internals@lists.php.net
 Subject: RE: [PHP-DEV] RE: Ext/OpenSSL patch


 So even Zend has abandoned PHP 6 development? :D
 And here I thought HEAD was meant for active development and
 you just MFH to any active branch were certain stuff goes..
 Committing patch and then backporting it after several month is big headache
 for me.
 I belive, nobody will use it in PHP6.
 
 I'm one that will test it, as already stated.
 
 That being said, I understand your concerns but remember that we are
 talking about mostly binary strings operation here. The differences
 between 5.x and 6.x for such code are very very small (and can be
 completely removed by using a couple of nice #define).
 
 Anyway, I can't force you to actually use our development branch...
 
 --Pierre
 

Concerning ext/openssl feature enhancements I wanted to remind of my CRL
patch (#40046) which could be committed to HEAD. I recently built new
patches against HEAD and PHP_5_2 which can be found here:

http://mbechler.eenterphace.org/php6-openssl-crl.patch
http://mbechler.eenterphace.org/php5-openssl-crl.patch

(unfortunatly I've somehow lost my bug password :|)


best regards

Moritz

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



[PHP-DEV] [PATCH] OpenSSL CRL Support

2007-01-06 Thread Moritz Bechler

Hi,

I already asked for comments on inclusion of OpenSSL CRL support in 
ext/openssl some time ago (I had a independend extension at this point).
As I continued working on it I realized that making this an independend 
extension makes me to reinvent/reimplement the wheel and makes it 
impossible to have ext/openssl and the CRL support to integrate nicely, 
so I wrote a patch to include it in ext/openssl.


In fact, having Marc Delling's PKCS#12 patch and mine applied makes it 
possible to write basic but real PKI-CA applications in PHP, so I think 
it would be nice to have this.


I know that there are not that many people who need this but I think 
this is true for nearly the whole openssl extension except for the 
stream wrapper. (maybe we should consider splitting it up?)


You find a patch (hopefully I got your conding standards right ;)) 
attached, but I should take careful review because this actually is my 
first work on PHP extensions and I'm also not used to writing C code.
I can/will provide a test (what kind of tests should I supply?) and 
documentation when needed.



Moritz Bechler
Index: ext/openssl/openssl.c
===
RCS file: /repository/php-src/ext/openssl/openssl.c,v
retrieving revision 1.98.2.5.2.25
diff -u -r1.98.2.5.2.25 openssl.c
--- ext/openssl/openssl.c	1 Jan 2007 09:36:04 -	1.98.2.5.2.25
+++ ext/openssl/openssl.c	6 Jan 2007 19:48:11 -
@@ -15,6 +15,7 @@
| Authors: Stig Venaas [EMAIL PROTECTED]|
|  Wez Furlong [EMAIL PROTECTED]  |
|  Sascha Kettler [EMAIL PROTECTED]|
+   |  Moritz Bechler [EMAIL PROTECTED] (CRL support) |
+--+
  */
 
@@ -42,6 +43,7 @@
 #include openssl/conf.h
 #include openssl/rand.h
 #include openssl/ssl.h
+#include openssl/ocsp.h
 
 #define DEFAULT_KEY_LENGTH	512
 #define MIN_KEY_LENGTH		384
@@ -128,6 +130,13 @@
 	PHP_FE(openssl_pkcs7_decrypt,		NULL)
 	PHP_FE(openssl_pkcs7_sign,			NULL)
 	PHP_FE(openssl_pkcs7_encrypt,		NULL)
+	
+/* for CRL creation */
+	PHP_FE(openssl_crl_new, NULL)
+	PHP_FE(openssl_crl_revoke_cert_by_serial, NULL)
+	PHP_FE(openssl_crl_revoke_cert, NULL)
+	PHP_FE(openssl_crl_export, second_arg_force_ref)
+	PHP_FE(openssl_crl_export_file, NULL)
 
 	PHP_FE(openssl_private_encrypt,		second_arg_force_ref)
 	PHP_FE(openssl_private_decrypt,		second_arg_force_ref)
@@ -165,8 +174,19 @@
 static int le_key;
 static int le_x509;
 static int le_csr;
+static int le_crl;
 static int ssl_stream_data_index;
 
+
+/* {{{ */
+struct php_x509_crl {
+	X509_CRL *crl;
+	X509 *cacert;
+	long lifetime;
+	int forcev2;
+};
+/* }}} */
+
 int php_openssl_get_x509_list_id(void) /* {{{ */
 {
 	return le_x509;
@@ -194,6 +214,22 @@
 	X509_REQ * csr = (X509_REQ*)rsrc-ptr;
 	X509_REQ_free(csr);
 }
+
+static void php_crl_free(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+	struct php_x509_crl *res = (struct php_x509_crl*)rsrc-ptr;
+
+	if(res-crl != NULL) {
+		X509_CRL_free(res-crl);
+	}
+
+	if(res-cacert != NULL) {
+		X509_free(res-cacert);
+	}
+
+	efree(res);
+}
+
 /* }}} */
 
 /* {{{ openssl safe_mode  open_basedir checks */
@@ -637,7 +673,8 @@
 	le_key = zend_register_list_destructors_ex(php_pkey_free, NULL, OpenSSL key, module_number);
 	le_x509 = zend_register_list_destructors_ex(php_x509_free, NULL, OpenSSL X.509, module_number);
 	le_csr = zend_register_list_destructors_ex(php_csr_free, NULL, OpenSSL X.509 CSR, module_number);
-
+	le_crl = zend_register_list_destructors_ex(php_crl_free, NULL, OpenSSL X.509 CRL, module_number);
+	
 	SSL_library_init();
 	OpenSSL_add_all_ciphers();
 	OpenSSL_add_all_digests();
@@ -693,7 +730,23 @@
 	REGISTER_LONG_CONSTANT(OPENSSL_CIPHER_RC2_64, PHP_OPENSSL_CIPHER_RC2_64, CONST_CS|CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT(OPENSSL_CIPHER_DES, PHP_OPENSSL_CIPHER_DES, CONST_CS|CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT(OPENSSL_CIPHER_3DES, PHP_OPENSSL_CIPHER_3DES, CONST_CS|CONST_PERSISTENT);
-
+	
+	/* OCSP revokation states */
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_NOSTATUS, OCSP_REVOKED_STATUS_NOSTATUS, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_UNSPECIFIED, OCSP_REVOKED_STATUS_UNSPECIFIED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_KEYCOMPROMISE, OCSP_REVOKED_STATUS_KEYCOMPROMISE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_CACOMPROMISE, OCSP_REVOKED_STATUS_CACOMPROMISE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_SUPERSEDED, OCSP_REVOKED_STATUS_SUPERSEDED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT(OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, CONST_CS | CONST_PERSISTENT

Re: [PHP-DEV] [PATCH] OpenSSL CRL Support

2007-01-06 Thread Moritz Bechler

Hi Pierre,

Hello Moritz,

On 1/6/07, Moritz Bechler [EMAIL PROTECTED] wrote:

Hi,

I already asked for comments on inclusion of OpenSSL CRL support in
ext/openssl some time ago (I had a independend extension at this point).


Do you have a bug id please? If not please open one.


Open a feature request #40046. Hope that is sufficient.


Moritz Bechler

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



Re: [PHP-DEV] PHP 5.2.0 Openssl PKCS12 patch

2006-12-16 Thread Moritz Bechler
Hi

 Hello, I'm Marc and I'm new to this list. Whew! That was easy!

 I've read in the archive about a patch for supporting openssl pkcs12,

 First, thanks for this patch :)

Quite nice you did this, I was just thinking about doing it myself ;)

 but nothing seems to be done so far. Since I was missing the same
 thing when trying to code a quick-and-dirty certificate management
 webapp I decided to write a patch by myself. Is there still need for
 a patch introducing such functions? To whom should I post it? (I've
 included it in this posting for discussion) Where does the
 documentation go?

I also work on an extension wrapping OpenSSL's CRL generation and OCSP
parsing/generation functions and wonder whether it makes sense to have
two or more extensions wrapping OpenSSL functionality or whether there is
public interest in having these functions in the stock distribution?

Moritz Bechler

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