summaryrefslogtreecommitdiff
path: root/ext/session/mod_mm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/session/mod_mm.c')
-rw-r--r--ext/session/mod_mm.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c
index 0014b81a0..a8859cad4 100644
--- a/ext/session/mod_mm.c
+++ b/ext/session/mod_mm.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mod_mm.c,v 1.46.2.1 2006/01/01 12:50:12 sniper Exp $ */
+/* $Id: mod_mm.c,v 1.46.2.1.2.5 2007/02/27 03:28:16 iliaa Exp $ */
#include "php.h"
@@ -253,28 +253,34 @@ PHP_MINIT_FUNCTION(ps_mm)
{
int save_path_len = strlen(PS(save_path));
int mod_name_len = strlen(sapi_module.name);
+ int euid_len;
char *ps_mm_path, euid[30];
int ret;
ps_mm_instance = calloc(sizeof(*ps_mm_instance), 1);
- if (!ps_mm_instance)
+ if (!ps_mm_instance) {
return FAILURE;
+ }
- if (!sprintf(euid,"%d", geteuid()))
+ if (!(euid_len = slprintf(euid, sizeof(euid), "%d", geteuid()))) {
return FAILURE;
+ }
- /* Directory + '/' + File + Module Name + Effective UID + \0 */
- ps_mm_path = emalloc(save_path_len+1+sizeof(PS_MM_FILE)+mod_name_len+strlen(euid)+1);
+ /* Directory + '/' + File + Module Name + Effective UID + \0 */
+ ps_mm_path = emalloc(save_path_len + 1 + (sizeof(PS_MM_FILE) - 1) + mod_name_len + euid_len + 1);
- memcpy(ps_mm_path, PS(save_path), save_path_len + 1);
- if (save_path_len > 0 && ps_mm_path[save_path_len - 1] != DEFAULT_SLASH) {
+ memcpy(ps_mm_path, PS(save_path), save_path_len);
+ if (PS(save_path)[save_path_len - 1] != DEFAULT_SLASH) {
ps_mm_path[save_path_len] = DEFAULT_SLASH;
- ps_mm_path[save_path_len+1] = '\0';
+ save_path_len++;
}
- strcat(ps_mm_path, PS_MM_FILE);
- strcat(ps_mm_path, sapi_module.name);
- strcat(ps_mm_path, euid);
-
+ memcpy(ps_mm_path + save_path_len, PS_MM_FILE, sizeof(PS_MM_FILE) - 1);
+ save_path_len += sizeof(PS_MM_FILE) - 1;
+ memcpy(ps_mm_path + save_path_len, sapi_module.name, mod_name_len);
+ save_path_len += mod_name_len;
+ memcpy(ps_mm_path + save_path_len, euid, euid_len);
+ ps_mm_path[save_path_len + euid_len] = '\0';
+
ret = ps_mm_initialize(ps_mm_instance, ps_mm_path);
efree(ps_mm_path);