Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c
| From: | Andrey Hristov | Date: | Wed, 05 Apr 2006 11:44:59 +0000 |
| Subject: | Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c | ||
| References: | 1 | Groups: | php.zend-engine.cvs |
| Request: | Send a blank email to php-zend-engine-cvs+get-4791@lists.php.net to get a copy of this message | ||
Hi Antony,
would you add a test case to the test suite?
Thanks,
Andrey
Antony Dovgal wrote:
tony2001 Wed Apr 5 11:36:29 2006 UTCModified files: /ZendEngine2 zend_builtin_functions.c Log:MF51: fix #36944 (strncmp & strncasecmp do not return false on negative string length) http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.311&r2=1.312&diff_format=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.311 ZendEngine2/zend_builtin_functions.c:1.312 --- ZendEngine2/zend_builtin_functions.c:1.311 Tue Mar 28 19:43:37 2006 +++ ZendEngine2/zend_builtin_functions.c Wed Apr 5 11:36:28 2006 @@ -17,7 +17,7 @@+----------------------------------------------------------------------+*/ -/* $Id: zend_builtin_functions.c,v 1.311 2006/03/28 19:43:37 tony2001 Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.312 2006/04/05 11:36:28 tony2001 Exp $ */ #include "zend.h" #include "zend_API.h" @@ -333,6 +333,12 @@ &s1_type, &s2, &s2_len, &s2_type, &count) == FAILURE) { return; } + + if (count < 0) { + zend_error(E_WARNING, "Length must be greater than or equal to 0"); + RETURN_FALSE; + } + if (s1_type == IS_UNICODE) { RETURN_LONG(zend_u_binary_strncmp(s1, s1_len, s2, s2_len, count)); } else { @@ -376,6 +382,12 @@ &s1_type, &s2, &s2_len, &s2_type, &len) == FAILURE) { return; } + + if (len < 0) { + zend_error(E_WARNING, "Length must be greater than or equal to 0"); + RETURN_FALSE; + } + if (s1_type == IS_UNICODE) { RETURN_LONG(zend_u_binary_strncasecmp(s1, s1_len, s2, s2_len, len)); } else {