[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] cvs: pecl(PECL_4_3) /sqlite sqlite.c  /sqlite/tests sqlite_027.phpt
From:       "Ilia Alshanetsky" <iliaa () php ! net>
Date:       2004-02-27 0:30:46
Message-ID: cvsiliaa1077841846 () cvsserver
[Download RAW message or body]

iliaa		Thu Feb 26 19:30:46 2004 EDT

  Added files:                 (Branch: PECL_4_3)
    /pecl/sqlite/tests	sqlite_027.phpt 

  Modified files:              
    /pecl/sqlite	sqlite.c 
  Log:
  MFH: Fixed possible crash inside sqlite_escape_string() and 
  sqlite_udf_encode_binary().
  
  
http://cvs.php.net/diff.php/pecl/sqlite/sqlite.c?r1=1.62.2.16&r2=1.62.2.17&ty=u
Index: pecl/sqlite/sqlite.c
diff -u pecl/sqlite/sqlite.c:1.62.2.16 pecl/sqlite/sqlite.c:1.62.2.17
--- pecl/sqlite/sqlite.c:1.62.2.16	Fri Jan 16 19:29:37 2004
+++ pecl/sqlite/sqlite.c	Thu Feb 26 19:30:45 2004
@@ -17,7 +17,7 @@
    |          Marcus Boerger <helly@php.net>                              |
    +----------------------------------------------------------------------+
 
-   $Id: sqlite.c,v 1.62.2.16 2004/01/17 00:29:37 edink Exp $ 
+   $Id: sqlite.c,v 1.62.2.17 2004/02/27 00:30:45 iliaa Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -669,7 +669,7 @@
 {
 	php_info_print_table_start();
 	php_info_print_table_header(2, "SQLite support", "enabled");
-	php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: \
sqlite.c,v 1.62.2.16 2004/01/17 00:29:37 edink Exp $"); +	php_info_print_table_row(2, \
"PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.62.2.17 \
2004/02/27 00:30:45 iliaa Exp $");  php_info_print_table_row(2, "SQLite Library", \
sqlite_libversion());  php_info_print_table_row(2, "SQLite Encoding", \
sqlite_libencoding());  php_info_print_table_end();
@@ -1736,7 +1736,7 @@
 		/* binary string */
 		int enclen;
 		
-		ret = emalloc( 1 + ((256 * stringlen + 1262) / 253) );
+		ret = emalloc( 1 + 5 + stringlen * (256 / 253) );
 		ret[0] = '\x01';
 		enclen = sqlite_encode_binary((const unsigned char*)string, stringlen, ret+1);
 		RETVAL_STRINGL(ret, enclen+1, 0);
@@ -1941,7 +1941,7 @@
 		int enclen;
 		char *ret;
 		
-		ret = emalloc( 1 + ((256 * datalen + 1262) / 253) );
+		ret = emalloc( 1 + 5 + datalen * (256 / 253) );
 		ret[0] = '\x01';
 		enclen = sqlite_encode_binary((const unsigned char*)data, datalen, ret+1);
 		RETVAL_STRINGL(ret, enclen+1, 0);

http://cvs.php.net/co.php/pecl/sqlite/tests/sqlite_027.phpt?r=1.1&p=1
Index: pecl/sqlite/tests/sqlite_027.phpt
+++ pecl/sqlite/tests/sqlite_027.phpt
--TEST--
sqlite: crash inside sqlite_escape_string() & sqlite_udf_encode_binary
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded("sqlite")) print "skip"; ?>
--FILE--
<?php
	var_dump(strlen(sqlite_escape_string(str_repeat("\0", 20000000))));
	var_dump(strlen(sqlite_udf_encode_binary(str_repeat("\0", 20000000))));
?>
--EXPECT--
int(20000002)
int(20000002)

-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic