summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan2010-03-05 23:47:10 +0100
committerStefan2010-03-05 23:47:10 +0100
commitc54d1f40594b6bc592dc22e55b7683b2ec9ec8c9 (patch)
treec9735ffff70cd09ab1e50c874183cb969289bd8e
parent8d22a97250131c7246ee58f35d27445a15c619c3 (diff)
Fix the session serializer protection
-rw-r--r--session.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/session.c b/session.c
index db1e97a..64b4822 100644
--- a/session.c
+++ b/session.c
@@ -30,8 +30,14 @@
30#include "php_ini.h" 30#include "php_ini.h"
31#include "php_suhosin.h" 31#include "php_suhosin.h"
32#include "ext/standard/base64.h" 32#include "ext/standard/base64.h"
33#include "ext/standard/php_smart_str.h"
34#include "ext/standard/php_var.h"
33#include "sha256.h" 35#include "sha256.h"
34 36
37#if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
38# include "ext/hash/php_hash.h"
39#endif
40
35#define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name TSRMLS_DC 41#define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name TSRMLS_DC
36#define PS_CLOSE_ARGS void **mod_data TSRMLS_DC 42#define PS_CLOSE_ARGS void **mod_data TSRMLS_DC
37#define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen TSRMLS_DC 43#define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen TSRMLS_DC
@@ -253,7 +259,7 @@ static php_ps_globals_43_44 *session_globals = NULL;
253#define SESSION_G(v) (session_globals->v) 259#define SESSION_G(v) (session_globals->v)
254#endif 260#endif
255 261
256ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC); 262ps_serializer *(*suhosin_find_ps_serializer)(char *name TSRMLS_DC) = NULL;
257 263
258#define PS_ENCODE_VARS \ 264#define PS_ENCODE_VARS \
259 char *key; \ 265 char *key; \
@@ -853,8 +859,8 @@ void suhosin_hook_session(TSRMLS_D)
853 859
854 /* Protect the PHP serializer from ! attacks */ 860 /* Protect the PHP serializer from ! attacks */
855# if PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 2) 861# if PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 2)
856 serializer = _php_find_ps_serialize("php" TSRMLS_CC); 862 serializer = SESSION_G(serializer);
857 if (serializer != NULL) { 863 if (serializer != NULL && strcmp(serializer->name, "php")==0) {
858 serializer->encode = suhosin_session_encode; 864 serializer->encode = suhosin_session_encode;
859 } 865 }
860#endif 866#endif