Date: 08/04/98
- Next message: steffann: "[PHP-DEV] CVS update: php3/functions"
- Previous message: steffann: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: APIS: "Re: [PHP-DEV] CVS update: php3"
- Reply: APIS: "Re: [PHP-DEV] CVS update: php3"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tuesday August 4, 1998 @ 20:33
Author: steffann
Update of /repository/php3
In directory asf:/tmp/cvs-serv24042
Modified Files:
php3_realpath.c
Log Message:
fopen_basedir now also works on directories.
_php3_realpath now appends a / when the input-string points to a directory.
Index: php3/php3_realpath.c
diff -c php3/php3_realpath.c:1.2 php3/php3_realpath.c:1.3
*** php3/php3_realpath.c:1.2 Mon Aug 3 17:12:27 1998
--- php3/php3_realpath.c Tue Aug 4 20:33:54 1998
***************
*** 41,46 ****
--- 41,50 ----
#define MAXSYMLINKS 32
#endif
+ #ifndef S_ISDIR
+ #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
+ #endif
+
char *_php3_realpath(char *path, char resolved_path []) {
char path_construction[MAXPATHLEN]; /* We build the result in here */
char *writepos; /* Position to write next char */
***************
*** 51,56 ****
--- 55,62 ----
char buf[MAXPATHLEN]; /* Buffer for readlink */
int linklength; /* The result from readlink */
int linkcount = 0; /* Count symlinks to avoid loops */
+
+ struct stat filestat; /* result from stat */
/* Set the work-position to the beginning of the given path */
strcpy(path_copy, path);
***************
*** 238,243 ****
--- 244,262 ----
}
*writepos = 0;
#endif /* WIN32|WINNT */
+ }
+
+ /* Check if the resolved path is a directory */
+ if (stat(path_construction, &filestat) != 0) return NULL;
+ if (S_ISDIR(filestat.st_mode)) {
+ /* It's a directory, append a / if needed */
+ if (*(writepos-1) != '/') {
+ /* Check for overflow */
+ if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL;
+
+ *writepos++ = '/';
+ *writepos = 0;
+ }
}
strcpy(resolved_path, path_construction);
- Next message: steffann: "[PHP-DEV] CVS update: php3/functions"
- Previous message: steffann: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: APIS: "Re: [PHP-DEV] CVS update: php3"
- Reply: APIS: "Re: [PHP-DEV] CVS update: php3"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

