summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2004-03-07 22:35:26 +0000
committerSascha Schumann <sas@php.net>2004-03-07 22:35:26 +0000
commit048e66b2a9b0ce089b15920618044a3834feb276 (patch)
treed2070e926c1c417250ef85c3f9f471be59d90f54
parent70757063a7cca44d333c9d6c209bb676d0d35eb4 (diff)
downloadphp-git-048e66b2a9b0ce089b15920618044a3834feb276.tar.gz
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.)
-rw-r--r--ext/sqlite/sess_sqlite.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/sqlite/sess_sqlite.c b/ext/sqlite/sess_sqlite.c
index c9616bc07d..8789cd6109 100644
--- a/ext/sqlite/sess_sqlite.c
+++ b/ext/sqlite/sess_sqlite.c
@@ -142,7 +142,7 @@ PS_WRITE_FUNC(sqlite)
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);