cvs: php4 /main fopen_wrappers.c
| From: | Zeev Suraski | Date: | Mon, 16 Jul 2001 13:48:07 +0000 |
| Subject: | cvs: php4 /main fopen_wrappers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6243@lists.php.net to get a copy of this message | ||
zeev Mon Jul 16 09:48:07 2001 EDT
Modified files:
/php4/main fopen_wrappers.c
Log:
Fix the crash Joey found
Index: php4/main/fopen_wrappers.c
diff -u php4/main/fopen_wrappers.c:1.124 php4/main/fopen_wrappers.c:1.125
--- php4/main/fopen_wrappers.c:1.124 Mon Jul 16 09:31:55 2001
+++ php4/main/fopen_wrappers.c Mon Jul 16 09:48:07 2001
@@ -16,7 +16,7 @@
| Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: fopen_wrappers.c,v 1.124 2001/07/16 13:31:55 zeev Exp $ */
+/* $Id: fopen_wrappers.c,v 1.125 2001/07/16 13:48:07 zeev Exp $ */
/* {{{ includes
*/
@@ -465,18 +465,18 @@
exec_fname_length = strlen(exec_fname);
path_length = strlen(path);
- while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])) {
+ while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length]));
+ if ((exec_fname && exec_fname[0] == '[')
+ || exec_fname_length<=0) {
+ /* [no active file] or no path */
+ pathbuf = estrdup(path);
+ } else {
+ pathbuf = (char *) emalloc(exec_fname_length + path_length +1 +1);
+ memcpy(pathbuf, path, path_length);
+ pathbuf[path_length] = DEFAULT_DIR_SEPARATOR;
+ memcpy(pathbuf+path_length+1, exec_fname, exec_fname_length);
+ pathbuf[path_length + exec_fname_length +1] = '\0';
}
- if (exec_fname && exec_fname[0] == '[') {
- /* [no active file] */
- exec_fname_length = 0;
- }
-
- pathbuf = (char *) emalloc(exec_fname_length + path_length +1 +1);
- memcpy(pathbuf, path, path_length);
- pathbuf[path_length] = DEFAULT_DIR_SEPARATOR;
- memcpy(pathbuf+path_length+1, exec_fname, exec_fname_length);
- pathbuf[path_length + exec_fname_length +1] = '\0';
} else {
pathbuf = estrdup(path);
}