summaryrefslogtreecommitdiff
path: root/ext/session
diff options
context:
space:
mode:
Diffstat (limited to 'ext/session')
-rw-r--r--ext/session/config.m43
-rw-r--r--ext/session/config.w322
-rw-r--r--ext/session/mod_files.c2
-rw-r--r--ext/session/mod_files.h2
-rw-r--r--ext/session/mod_mm.c2
-rw-r--r--ext/session/mod_mm.h2
-rw-r--r--ext/session/mod_user.c2
-rw-r--r--ext/session/mod_user.h2
-rw-r--r--ext/session/php_session.h2
-rw-r--r--ext/session/session.c28
-rw-r--r--ext/session/tests/031.phpt22
11 files changed, 48 insertions, 21 deletions
diff --git a/ext/session/config.m4 b/ext/session/config.m4
index 7286a6b77..8a0d4c0f8 100644
--- a/ext/session/config.m4
+++ b/ext/session/config.m4
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.28 2005/05/29 23:16:44 sniper Exp $
+dnl $Id: config.m4 286445 2009-07-28 08:59:08Z tony2001 $
dnl
PHP_ARG_ENABLE(session, whether to enable PHP sessions,
@@ -12,6 +12,7 @@ if test "$PHP_SESSION" != "no"; then
PHP_PWRITE_TEST
PHP_PREAD_TEST
PHP_NEW_EXTENSION(session, session.c mod_files.c mod_mm.c mod_user.c, $ext_shared)
+ PHP_ADD_EXTENSION_DEP(session, hash, true)
PHP_SUBST(SESSION_SHARED_LIBADD)
PHP_INSTALL_HEADERS(ext/session, [php_session.h mod_files.h mod_user.h])
AC_DEFINE(HAVE_PHP_SESSION,1,[ ])
diff --git a/ext/session/config.w32 b/ext/session/config.w32
index 4d5dcd31d..353ff73f8 100644
--- a/ext/session/config.w32
+++ b/ext/session/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.1 2003/12/02 23:16:56 wez Exp $
+// $Id: config.w32 145409 2003-12-02 23:17:04Z wez $
// vim:ft=javascript
ARG_ENABLE("session", "session support", "yes");
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 105f6d597..045acdfab 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_files.c,v 1.100.2.3.2.10.2.5 2009/05/18 16:10:09 jani Exp $ */
+/* $Id: mod_files.c 280729 2009-05-18 16:10:09Z jani $ */
#include "php.h"
diff --git a/ext/session/mod_files.h b/ext/session/mod_files.h
index bbfe69801..2522f6f28 100644
--- a/ext/session/mod_files.h
+++ b/ext/session/mod_files.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_files.h,v 1.11.2.1.2.1.2.2 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: mod_files.h 272370 2008-12-31 11:15:49Z sebastian $ */
#ifndef MOD_FILES_H
#define MOD_FILES_H
diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c
index e5ba2fbe5..37623da39 100644
--- a/ext/session/mod_mm.c
+++ b/ext/session/mod_mm.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_mm.c,v 1.46.2.1.2.5.2.3 2009/05/18 16:10:09 jani Exp $ */
+/* $Id: mod_mm.c 280729 2009-05-18 16:10:09Z jani $ */
#include "php.h"
diff --git a/ext/session/mod_mm.h b/ext/session/mod_mm.h
index 085090f6e..983424f9f 100644
--- a/ext/session/mod_mm.h
+++ b/ext/session/mod_mm.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_mm.h,v 1.12.2.1.2.1.2.2 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: mod_mm.h 272370 2008-12-31 11:15:49Z sebastian $ */
#ifndef MOD_MM_H
#define MOD_MM_H
diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c
index 1449a848c..f1e922fd1 100644
--- a/ext/session/mod_user.c
+++ b/ext/session/mod_user.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_user.c,v 1.29.2.1.2.1.2.4 2009/05/18 16:10:09 jani Exp $ */
+/* $Id: mod_user.c 280729 2009-05-18 16:10:09Z jani $ */
#include "php.h"
#include "php_session.h"
diff --git a/ext/session/mod_user.h b/ext/session/mod_user.h
index 88958df49..3ee546e4d 100644
--- a/ext/session/mod_user.h
+++ b/ext/session/mod_user.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_user.h,v 1.14.2.1.2.1.2.3 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: mod_user.h 272370 2008-12-31 11:15:49Z sebastian $ */
#ifndef MOD_USER_H
#define MOD_USER_H
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
index 8dafb5303..4dcab6c21 100644
--- a/ext/session/php_session.h
+++ b/ext/session/php_session.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_session.h,v 1.101.2.2.2.5.2.6 2009/05/18 16:10:09 jani Exp $ */
+/* $Id: php_session.h 280729 2009-05-18 16:10:09Z jani $ */
#ifndef PHP_SESSION_H
#define PHP_SESSION_H
diff --git a/ext/session/session.c b/ext/session/session.c
index a4469b218..05a66f231 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: session.c,v 1.417.2.8.2.40.2.22 2009/05/18 16:10:09 jani Exp $ */
+/* $Id: session.c 286443 2009-07-28 08:54:23Z tony2001 $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -347,7 +347,6 @@ static char *bin_to_readable(char *in, size_t inlen, char *out, char nbits) /* {
}
/* }}} */
-#define PS_ID_INITIAL_SIZE 100
PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
{
PHP_MD5_CTX md5_context;
@@ -358,7 +357,7 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
unsigned char *digest;
int digest_len;
int j;
- char *buf;
+ char *buf, *outid;
struct timeval tv;
zval **array;
zval **token;
@@ -406,6 +405,7 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
efree(buf);
return NULL;
}
+ efree(buf);
if (PS(entropy_length) > 0) {
int fd;
@@ -461,20 +461,16 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The ini setting hash_bits_per_character is out of range (should be 4, 5, or 6) - using 4 for now");
}
-
- if (PS_ID_INITIAL_SIZE < ((digest_len + 2) * (8 / PS(hash_bits_per_character))) ) {
- /* 100 bytes is enough for most, but not all hash algos */
- buf = erealloc(buf, (digest_len + 2) * (8 / PS(hash_bits_per_character)) );
- }
-
- j = (int) (bin_to_readable((char *)digest, digest_len, buf, PS(hash_bits_per_character)) - buf);
+
+ outid = emalloc((digest_len + 2) * ((8.0f / PS(hash_bits_per_character)) + 0.5));
+ j = (int) (bin_to_readable((char *)digest, digest_len, outid, PS(hash_bits_per_character)) - outid);
efree(digest);
if (newlen) {
*newlen = j;
}
- return buf;
+ return outid;
}
/* }}} */
@@ -2252,8 +2248,16 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */
}
/* }}} */
+static const zend_module_dep session_deps[] = { /* {{{ */
+ ZEND_MOD_OPTIONAL("hash")
+ {NULL, NULL, NULL}
+};
+/* }}} */
+
zend_module_entry session_module_entry = {
- STANDARD_MODULE_HEADER,
+ STANDARD_MODULE_HEADER_EX,
+ NULL,
+ session_deps,
"session",
session_functions,
PHP_MINIT(session), PHP_MSHUTDOWN(session),
diff --git a/ext/session/tests/031.phpt b/ext/session/tests/031.phpt
new file mode 100644
index 000000000..e8deb3dac
--- /dev/null
+++ b/ext/session/tests/031.phpt
@@ -0,0 +1,22 @@
+--TEST--
+setting hash_function to sha512 and hash_bits_per_character > 4 should not crash
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--INI--
+session.use_cookies=0
+session.cache_limiter=
+session.serialize_handler=php
+session.save_handler=files
+session.hash_function=sha512
+session.hash_bits_per_character=5
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+session_start();
+session_regenerate_id(TRUE);
+
+print "I live\n";
+?>
+--EXPECT--
+I live