sas             Sun Mar  7 17:35:27 2004 EDT

  Modified files:              
    /php-src/ext/sqlite sess_sqlite.c 
  Log:
  Avoid using floating point arithmetic and rely on safe_emalloc
  for the multiplication.
  
  The actual size requirement is spelled out as:
  
  ** The result is written into a preallocated output buffer "out".
  ** "out" must be able to hold at least 2 +(257*n)/254 bytes.
  ** In other words, the output will be expanded by as much as 3
  ** bytes for every 254 bytes of input plus 2 bytes of fixed overhead.
  ** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.)
  
  
http://cvs.php.net/diff.php/php-src/ext/sqlite/sess_sqlite.c?r1=1.15&r2=1.16&ty=u
Index: php-src/ext/sqlite/sess_sqlite.c
diff -u php-src/ext/sqlite/sess_sqlite.c:1.15 php-src/ext/sqlite/sess_sqlite.c:1.16
--- php-src/ext/sqlite/sess_sqlite.c:1.15       Sun Mar  7 16:57:50 2004
+++ php-src/ext/sqlite/sess_sqlite.c    Sun Mar  7 17:35:26 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sess_sqlite.c,v 1.15 2004/03/07 21:57:50 iliaa Exp $ */
+/* $Id: sess_sqlite.c,v 1.16 2004/03/07 22:35:26 sas Exp $ */
 
 #include "php.h"
 
@@ -142,7 +142,7 @@
        
        t = time(NULL);
 
-       binary = emalloc(1 + 5 + vallen * ((float) 256 / (float) 253));
+       binary = safe_emalloc(1 + vallen / 254, 257, 3);
        binlen = sqlite_encode_binary((const unsigned char*)val, vallen, binary);
        
        rv = sqlite_exec_printf(db, "REPLACE INTO session_data VALUES('%q', '%q', 
%d)", NULL, NULL, &error, key, binary, t);

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

Reply via email to