Permalink
Browse files

Fix PECL bug #18005

  • Loading branch information...
1 parent a777607 commit 0112d71831db26a63d98b590294ba8391c0f539f Mikko Koppanen committed Dec 30, 2010
Showing with 10 additions and 5 deletions.
  1. +2 −2 session.c
  2. +8 −3 session_funcs.c
View
4 session.c
@@ -238,7 +238,7 @@ PS_WRITE_FUNC(tokyo_tyrant)
efree(session->sess_rand);
efree(session->checksum);
efree(session->pk);
-
+
if (!php_tt_tokenize((char *)key, &(session->sess_rand), &(session->checksum), &(session->idx), &(session->pk) TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse the session id");
session->remap = 1;
@@ -253,7 +253,7 @@ PS_WRITE_FUNC(tokyo_tyrant)
if (!php_tt_validate(session->sess_rand, session->checksum, session->idx, session->pk, TOKYO_G(salt) TSRMLS_CC)) {
return FAILURE;
- }
+ }
if (!php_tt_save_sess_data(session->conn, session->sess_rand, session->pk, strlen(session->pk), val, vallen TSRMLS_CC)) {
server = php_tt_pool_get_server(session->pool, session->idx TSRMLS_CC);
View
11 session_funcs.c
@@ -196,8 +196,13 @@ char *php_tt_get_sess_data(php_tt_conn *conn, char *sess_rand, const char *pk, i
const char *checksum = tcmapget2(cols, "hash");
/* Make sure that we get back the expected session */
if (strcmp(checksum, sess_rand) == 0) {
- buffer = estrdup(tcmapget2(cols, "data"));
- *data_len = strlen(buffer);
+ const char *data;
+ data = tcmapget(cols, "data", sizeof("data") - 1, data_len);
+
+ if (data) {
+ buffer = emalloc(*data_len);
+ memcpy(buffer, data, *data_len);
+ }
} else {
*mismatch = 1;
}
@@ -225,7 +230,7 @@ zend_bool php_tt_save_sess_data(php_tt_conn *conn, char *rand_part, char *pk, in
/* store a record */
cols = tcmapnew();
- tcmapput2(cols, "data", data);
+ tcmapput(cols, "data", sizeof("data") - 1, data, data_len);
tcmapput2(cols, "hash", rand_part);
tcmapput2(cols, "ts", timestamp);

0 comments on commit 0112d71

Please sign in to comment.