cvs: php4 /main fopen-wrappers.c

From: Date: Fri, 16 Jun 2000 01:23:03 +0000
Subject: cvs: php4 /main fopen-wrappers.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-302@lists.php.net to get a copy of this message
andi Thu Jun 15 18:23:03 2000 EDT Modified files: /php4/main fopen-wrappers.c Log: - Last one for tonight. Make sure that we don't check uninitialized - memory Index: php4/main/fopen-wrappers.c diff -u php4/main/fopen-wrappers.c:1.66 php4/main/fopen-wrappers.c:1.67 --- php4/main/fopen-wrappers.c:1.66 Thu Jun 15 18:14:08 2000 +++ php4/main/fopen-wrappers.c Thu Jun 15 18:23:03 2000 @@ -16,7 +16,7 @@ | Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: fopen-wrappers.c,v 1.66 2000/06/16 01:14:08 andi Exp $ */ +/* $Id: fopen-wrappers.c,v 1.67 2000/06/16 01:23:03 andi Exp $ */ #include "php.h" #include "php_globals.h" @@ -325,26 +325,31 @@ } } else #endif + if (PG(doc_root) && path_info) { + length = strlen(PG(doc_root)); #ifdef PHP_WIN32 - if (PG(doc_root) && path_info && (IS_SLASH(*PG(doc_root)) - /* Check for absolute path. This should also use virtual cwd macros */ - || (PG(doc_root)[1] == ':' && IS_SLASH(PG(doc_root)[2]))) { + /* Check for absolute path. This should really use virtual cwd macros */ + if (IS_SLASH(*PG(doc_root) || (length >= 3 && PG(doc_root)[1] == ':' && IS_SLASH(PG(doc_root)[2]))) { #else - if (PG(doc_root) && path_info && IS_SLASH(*PG(doc_root))) { + if (IS_SLASH(*PG(doc_root))) { #endif - length = strlen(PG(doc_root)); - filename = emalloc(length + strlen(path_info) + 2); - if (filename) { - memcpy(filename, PG(doc_root), length); - if (!IS_SLASH(filename[length - 1])) /* length is never 0 */ - filename[length++] = DEFAULT_SLASH; - if (IS_SLASH(path_info[0])) - length--; - strcpy(filename + length, path_info); - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = filename; + length = strlen(PG(doc_root)); + filename = emalloc(length + strlen(path_info) + 2); + if (filename) { + memcpy(filename, PG(doc_root), length); + if (!IS_SLASH(filename[length - 1])) { /* length is never 0 */ + filename[length++] = DEFAULT_SLASH; + } + if (IS_SLASH(path_info[0])) { + length--; + } + strcpy(filename + length, path_info); + STR_FREE(SG(request_info).path_translated); + SG(request_info).path_translated = filename; + } } - } /* if doc_root && path_info */ + } /* if doc_root && path_info */ + if (!filename) { /* we have to free SG(request_info).path_translated here because php_destroy_request_info assumes that it will get

« previous php.cvs (#302) next »