Removing the obsolete code NEW_COMBINE_PATH 0 .
"Igor V. Melichev" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
[Log message beg] Removing the obsolete code NEW_COMBINE_PATH 0 . [Log message end] Branches : HEAD.
patch_lib.txt
(application/octet-stream, 11.3 KB) - not displayed
patch_src.txt
(text/plain, 31.3 KB)
Changes:
*** f:\casper\HEAD\gs\src\gp.h Tue Aug 19 14:32:58 2003
--- files\gs\src\gp.h Tue Aug 19 15:27:10 2003
***************
*** 22,28 ****
# define gp_INCLUDED
- /* A temporary switch for the new logics of file path concatenation : */
- #define NEW_COMBINE_PATH 1 /* 0 = old, 1 = new. */
-
#include "gstypes.h"
/*
--- 22,25 ----
***************
*** 196,228 ****
/* if 2nd param true, text mode if 2nd param false */
int gp_setmode_binary(FILE * pfile, bool mode);
-
- #if !NEW_COMBINE_PATH
- /* Answer whether a path string is not "bare" (returns true) i.e., */
- /* contains an absolute reference, an initial 'current directory' ref */
- /* or some form of relative reference to the parent directory. The */
- /* "non_bare" pathstrings are those for which it is not valid to prefix */
- /* a path (and expect the result to still be meaningful/valid). */
- /* */
- /* Some examples of non-bare pathstrings platform variants are: */
- /* unix: starts with '/' or './', or contains '../' */
- /* mac: starts with ':', or contains '::' */
- /* VMS: contains (starts with) directory '[ ]' spec. */
- /* Win: contains initial drive letter, initial '.', '/' or '\' */
- /* or contains '../' or '..\' */
- bool gp_pathstring_not_bare(const char *fname, uint len);
-
- /* Answer whether a file name contains a parent directory reference, */
- /* e.g., "../somefile". Currently used for security purposes. */
- /* Some example platform variants of this are: */
- /* unix: contains '../' Windows: contains '..\' or '../' */
- /* mac: contains '::' VMS: '[ ]' contains '-.' */
- bool gp_file_name_references_parent(const char *fname, uint len);
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The prefix directory/device is examined to */
- /* determine if a separator is needed and may return an empty string */
- /* in some cases (platform dependent). */
- const char *gp_file_name_concat_string(const char *prefix, uint plen);
- #endif
typedef enum {
--- 193,196 ----
*** f:\casper\HEAD\gs\src\gp_dosfs.c Fri Mar 7 17:21:21 2003
--- files\gs\src\gp_dosfs.c Tue Aug 19 15:26:51 2003
***************
*** 71,139 ****
const char gp_fmode_wb[] = "wb";
- #if !NEW_COMBINE_PATH
- /* Answer whether a path_string can meaningfully have a prefix applied */
- bool
- gp_pathstring_not_bare(const char *fname, unsigned len)
- { /* A file name is not bare if it contains a drive specifications */
- /* (second character is a :) or if it starts with a '.', '/' or '\\'*/
- /* or it contains '/../' (parent reference) */
- if ((len > 0) && ((*fname == '/') || (*fname == '\\') ||
- (*fname == '.') || ((len > 2) && (fname[1] == ':'))))
- return true;
- while (len-- > 3) {
- int c = *fname++;
-
- if (((c == '/') || (c == '\\')) &&
- ((len >= 3) && (bytes_compare(fname, 2, "..", 2) == 0) &&
- ((fname[2] == '/') || (fname[2] == '\\'))))
- return true;
- }
- return false;
- }
-
- /* Answer whether the file_name references the directory */
- /* containing the specified path (parent). */
- bool
- gp_file_name_references_parent(const char *fname, unsigned len)
- {
- int i = 0, last_sep_pos = -1;
-
- /* A file name references its parent directory if it starts */
- /* with ../ or ..\ or if one of these strings follows / or \ */
- while (i < len) {
- if (fname[i] == '/' || fname[i] == '\\') {
- last_sep_pos = i++;
- continue;
- }
- if (fname[i++] != '.')
- continue;
- if (i > last_sep_pos + 2 || (i < len && fname[i] != '.'))
- continue;
- i++;
- /* have separator followed by .. */
- if (i < len && (fname[i] == '/' || fname[i++] == '\\'))
- return true;
- }
- return false;
- }
-
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The prefix directory/device is examined to */
- /* determine if a separator is needed and may return an empty string */
- const char *
- gp_file_name_concat_string(const char *prefix, unsigned plen)
- {
- if (plen > 0)
- switch (prefix[plen - 1]) {
- case ':':
- case '/':
- case '\\':
- return "";
- };
- return "/";
- }
- #endif
-
/* -------------- Helpers for gp_file_name_combine_generic ------------- */
--- 71,74 ----
*** f:\casper\HEAD\gs\src\gp_iwatc.c Tue Jul 8 22:56:51 2003
--- files\gs\src\gp_iwatc.c Tue Aug 19 15:26:51 2003
***************
*** 129,138 ****
FILE *f;
! if (
! #if !NEW_COMBINE_PATH
! gp_pathstring_not_bare(prefix, prefix_length) ||
! #else
! gp_file_name_is_absolute(prefix, prefix_length) ||
! #endif
gp_gettmpdir(fname, &len) != 0
)
--- 129,133 ----
FILE *f;
! if (gp_file_name_is_absolute(prefix, prefix_length) ||
gp_gettmpdir(fname, &len) != 0
)
*** f:\casper\HEAD\gs\src\gp_macio.c Tue Aug 19 14:33:00 2003
--- files\gs\src\gp_macio.c Tue Aug 19 15:26:51 2003
***************
*** 459,568 ****
}
- /*
- {
- char thefname[256];
- strcpy (fname, (char *) prefix);
- {
- char newName[50];
-
- tmpnam (newName);
- strcat (fname, newName);
- }
-
- if ( strrchr(fname,':') == NULL )
- // sprintf((char *)&thefname[0],"%s%s\0",g_homeDir,fname);
- sprintf((char *)&thefname[0],"%s%s\0","",fname);
- else
- sprintf((char*)&thefname[0],"%s\0",fname);
-
- return gp_fopen (thefname, mode);
- }
- */
-
- #if !NEW_COMBINE_PATH
- /* Answer whether a path_string can meaningfully have a prefix applied */
- int
- gp_pathstring_not_bare(const char *fname, unsigned len) {
- /* Macintosh paths are not 'bare' i.e., cannot have a prefix */
- /* applied with predictable results if the string contains '::' */
- /* If a pathstring starts with ':' we also call it not_bare since */
- /* prefixing a 'somedir:' string would end up with '::' which will */
- /* move up a directory level. */
- /* While MacHD:somedir:xyz is a "root" or "absolute" reference we */
- /* assume that this syntax is actually somedir:subdir:xyz since the */
- /* HardDrive name will vary from site to site ("root" or "absolute" */
- /* references aren't really practical on Macintosh pre OS/X) */
- /* As far as we can tell, this whole area is confused on Mac since */
- /* root level references and current_directory references look the */
- /* same. */
-
- if (len != 0) {
- if (*fname == ':') { /* leading ':' */
- return 1; /* cannot be prefixed - not_bare, but */
- /* *IS* relative to the current dir. */
- } else {
- char *p;
- bool lastWasColon;
-
- for (len, p = (char *)fname, lastWasColon = 0; len > 0; len--, p++) {
- if (*p == ':') {
- if (lastWasColon != 0)
- return 1;
- else
- lastWasColon = 1;
- } else
- lastWasColon = 0;
- }
- return 0; /* pathstring *ASSUMED* bare */
- /* fixme: if the start of the pathstring up to the first ':'*/
- /* matches a drive name, then this is really an absolute */
- /* pathstring, and thus should be not_bare (return 1). */
- }
- } else
- return 0; /* empty path ?? */
- }
-
- /* Answer whether the file_name references the directory */
- /* containing the specified path (parent). */
- bool
- gp_file_name_references_parent(const char *fname, unsigned len)
- {
- int i = 0, last_sep_pos = -1;
-
- /* A file name references its parent directory if it starts */
- /* with ..: or :: or if one of these strings follows : */
- while (i < len) {
- if (fname[i] == ':') {
- if (last_sep_pos == i - 1)
- return true; /* also returns true is starts with ':' */
- last_sep_pos = i++;
- continue;
- }
- if (fname[i++] != '.')
- continue;
- if (i > last_sep_pos + 2 || (i < len && fname[i] != '.'))
- continue;
- i++;
- /* have separator followed by .. */
- if (i < len && (fname[i] == ':'))
- return true;
- }
- return false;
- }
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The prefix directory/device is examined to */
- /* determine if a separator is needed and may return an empty string */
- const char *
- gp_file_name_concat_string (const char *prefix, uint plen)
- {
- if ( plen > 0 && prefix[plen - 1] == ':' )
- return "";
- return ":";
- }
-
- #endif /* !NEW_COMBINE_PATH */
-
-
/* read a resource and copy the data into a buffer */
/* we don't have access to an allocator, nor any context for local */
--- 459,462 ----
*** f:\casper\HEAD\gs\src\gp_ntfs.c Mon May 12 10:11:53 2003
--- files\gs\src\gp_ntfs.c Tue Aug 19 15:26:51 2003
***************
*** 82,148 ****
const char gp_fmode_wb[] = "wb";
- #if !NEW_COMBINE_PATH
- /* Answer whether a path_string can meaningfully have a prefix applied */
- bool
- gp_pathstring_not_bare(const char *fname, unsigned len)
- { /* A file name is not bare if it contains a drive specifications */
- /* (second character is a :) or if it starts with a '.', '/' or '\\'*/
- /* or it contains '/../' (parent reference) */
- if ((len > 0) && ((*fname == '/') || (*fname == '\\') ||
- (*fname == '.') || ((len > 2) && (fname[1] == ':'))))
- return true;
- while (len-- > 3) {
- int c = *fname++;
-
- if (((c == '/') || (c == '\\')) &&
- ((len >= 3) && (bytes_compare(fname, 2, "..", 2) == 0) &&
- ((fname[2] == '/') || (fname[2] == '\\'))))
- return true;
- }
- return false;
- }
-
- /* Answer whether the file_name references the directory */
- /* containing the specified path (parent). */
- bool
- gp_file_name_references_parent(const char *fname, unsigned len)
- {
- int i = 0, last_sep_pos = -1;
-
- /* A file name references its parent directory if it starts */
- /* with ../ or ..\ or if one of these strings follows / or \ */
- while (i < len) {
- if (fname[i] == '/' || fname[i] == '\\') {
- last_sep_pos = i++;
- continue;
- }
- if (fname[i++] != '.')
- continue;
- if (i > last_sep_pos + 2 || (i < len && fname[i] != '.'))
- continue;
- i++;
- /* have separator followed by .. */
- if (i < len && (fname[i] == '/' || fname[i++] == '\\'))
- return true;
- }
- return false;
- }
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The file name is known to not be absolute. */
- const char *
- gp_file_name_concat_string(const char *prefix, uint plen)
- {
- if (plen > 0)
- switch (prefix[plen - 1]) {
- case ':':
- case '/':
- case '\\':
- return "";
- };
- return "/";
- }
- #endif
-
/* ------ File enumeration ------ */
--- 82,85 ----
*** f:\casper\HEAD\gs\src\gp_os2.c Tue Jul 8 22:56:51 2003
--- files\gs\src\gp_os2.c Tue Aug 19 15:26:51 2003
***************
*** 180,248 ****
const char gp_fmode_wb[] = "wb";
- #if !NEW_COMBINE_PATH
- /* Answer whether a path_string can meaningfully have a prefix applied */
- bool
- gp_pathstring_not_bare(const char *fname, uint len)
- { /* A file name is not bare if it contains a drive specifications */
- /* (second character is a :) or if it starts with a '.', '/' or '\\'*/
- /* or it contains '/../' (parent reference) */
- if ((len > 0) && ((*fname == '/') || (*fname == '\\') ||
- (*fname == '.') || ((len > 2) && (fname[1] == ':'))))
- return true;
- while (len-- > 3) {
- int c = *fname++;
-
- if (((c == '/') || (c == '\\')) &&
- ((len >= 3) && (bytes_compare(fname, 2, "..", 2) == 0) &&
- ((fname[2] == '/') || (fname[2] == '\\'))))
- return true;
- }
- return false;
- }
-
- /* Answer whether the file_name references the directory */
- /* containing the specified path (parent). */
- bool
- gp_file_name_references_parent(const char *fname, unsigned len)
- {
- int i = 0, last_sep_pos = -1;
-
- /* A file name references its parent directory if it starts */
- /* with ../ or ..\ or if one of these strings follows / or \ */
- while (i < len) {
- if (fname[i] == '/' || fname[i] == '\\') {
- last_sep_pos = i++;
- continue;
- }
- if (fname[i++] != '.')
- continue;
- if (i > last_sep_pos + 2 || (i < len && fname[i] != '.'))
- continue;
- i++;
- /* have separator followed by .. */
- if (i < len && (fname[i] == '/' || fname[i++] == '\\'))
- return true;
- }
- return false;
- }
-
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The prefix directory/device is examined to */
- /* determine if a separator is needed and may return an empty string */
- const char *
- gp_file_name_concat_string(const char *prefix, uint plen)
- {
- if (plen > 0)
- switch (prefix[plen - 1]) {
- case ':':
- case '/':
- case '\\':
- return "";
- };
- return "/";
- }
- #endif
-
/* ------ File enumeration ------ */
--- 180,183 ----
***************
*** 756,766 ****
int prefix_length = strlen(prefix);
! if (
! #if !NEW_COMBINE_PATH
! !gp_pathstring_not_bare(prefix, prefix_length)
! #else
! !gp_file_name_is_absolute(prefix, prefix_length)
! #endif
! ) {
temp = getenv("TMPDIR");
if (temp == 0)
--- 691,695 ----
int prefix_length = strlen(prefix);
! if (!gp_file_name_is_absolute(prefix, prefix_length)) {
temp = getenv("TMPDIR");
if (temp == 0)
***************
*** 782,791 ****
int len = gp_file_name_sizeof - prefix_length - 7;
! if (
! #if !NEW_COMBINE_PATH
! gp_pathstring_not_bare(prefix, prefix_length) ||
! #else
! gp_file_name_is_absolute(prefix, prefix_length) ||
! #endif
gp_gettmpdir(fname, &len) != 0)
*fname = 0;
--- 711,715 ----
int len = gp_file_name_sizeof - prefix_length - 7;
! if (gp_file_name_is_absolute(prefix, prefix_length) ||
gp_gettmpdir(fname, &len) != 0)
*fname = 0;
*** f:\casper\HEAD\gs\src\gp_unifn.c Fri Mar 7 17:21:21 2003
--- files\gs\src\gp_unifn.c Tue Aug 19 15:26:51 2003
***************
*** 32,94 ****
const char gp_fmode_wb[] = "w";
- #if !NEW_COMBINE_PATH
- /* Answer whether a path_string can meaningfully have a prefix applied */
- bool
- gp_pathstring_not_bare(const char *fname, unsigned len)
- {
- /* A file name is not bare if it starts with a '/' or a '.' or */
- /* it contains "/../" */
- if (len && (*fname == '.' || *fname == '/'))
- return true;
- while (len-- > 3) {
- int c = *fname++;
-
- if ((c == '/') &&
- ((len >= 3) && (bytes_compare(fname, 2, "..", 2) == 0) &&
- (fname[2] == '/')))
- return true;
- }
- return false;
- }
-
- /* Answer whether the file_name references the directory */
- /* containing the specified path (parent). */
- bool
- gp_file_name_references_parent(const char *fname, unsigned len)
- {
- int i = 0, last_sep_pos = -1;
-
- /* A file name references its parent directory if it starts */
- /* with ../ or if ../ follows a / */
- while (i < len) {
- if (fname[i] == '/') {
- last_sep_pos = i++;
- continue;
- }
- if (fname[i++] != '.')
- continue;
- if (i > last_sep_pos + 2 || (i < len && fname[i] != '.'))
- continue;
- i++;
- /* have separator followed by .. */
- if (i < len && fname[i] == '/')
- return true;
- }
- return false;
- }
-
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The prefix directory/device is examined to */
- /* determine if a separator is needed and may return an empty string */
- const char *
- gp_file_name_concat_string(const char *prefix, unsigned plen)
- {
- if (plen > 0 && prefix[plen - 1] == '/')
- return "";
- return "/";
- }
- #endif
-
/* -------------- Helpers for gp_file_name_combine_generic ------------- */
--- 32,35 ----
*** f:\casper\HEAD\gs\src\gp_unifs.c Tue Mar 4 14:00:40 2003
--- files\gs\src\gp_unifs.c Tue Aug 19 15:26:51 2003
***************
*** 62,72 ****
FILE *fp;
! if (
! #if !NEW_COMBINE_PATH
! gp_pathstring_not_bare(prefix, prefix_length)
! #else
! gp_file_name_is_absolute(prefix, prefix_length)
! #endif
! )
*fname = 0;
else if (gp_gettmpdir(fname, &len) != 0)
--- 62,66 ----
FILE *fp;
! if (gp_file_name_is_absolute(prefix, prefix_length))
*fname = 0;
else if (gp_gettmpdir(fname, &len) != 0)
*** f:\casper\HEAD\gs\src\gp_vms.c Tue Aug 19 14:33:01 2003
--- files\gs\src\gp_vms.c Tue Aug 19 15:26:51 2003
***************
*** 264,369 ****
}
- #if !NEW_COMBINE_PATH
- /* Answer whether a file name contains a directory/device specification, i.e.,
- * is absolute (not directory- or device-relative). Since for VMS, the concept
- * of an "absolute" file reference has no meaning. As Ghostscript is here
- * merely checking to see if it will make sense to paste a path to the front
- * of the file name, we use the VMS system service SYS$FILESCAN to check that
- * the file name has no node, device, root, or directory specification: if all
- * four of these items are missing from the file name then it is considered to
- * a relative file name to which a path may be prefixed. (Roots are associated
- * with rooted logical names.)
- */
-
- bool
- gp_pathstring_not_bare(const char *fname, unsigned len)
- {
- descrip str_desc;
-
- /* SYS$FILESCAN takes a uint *, but we want to extract bits. */
- union {
- uint i;
- struct {
- unsigned fscn$v_node:1;
- unsigned fscn$v_device:1;
- unsigned fscn$v_root:1;
- unsigned fscn$v_directory:1;
- unsigned fscn$v_name:1;
- unsigned fscn$v_type:1;
- unsigned fscn$v_version:1;
- unsigned fscn$v_fill_23:1;
- } s;
- } flags;
- uint zero = 0;
-
- str_desc.dsc$w_length = len;
- str_desc.dsc$a_pointer = (char *)fname;
- SYS$FILESCAN(&str_desc, &zero, &flags.i);
- if (flags.s.fscn$v_directory || flags.s.fscn$v_root ||
- flags.s.fscn$v_device || flags.s.fscn$v_node)
- return true;
- else
- return false;
- }
-
- /* Answer whether the file_name references the directory */
- /* containing the specified path (parent). */
- bool
- gp_file_name_references_parent(const char *fname, unsigned len)
- {
- int i = 0, last_sep_pos = -gp_file_name_sizeof;
-
- /* A file name references its parent directory if it contains -. */
- /* inside the [ ] part of the file specification */
- while (i < len && fname[i] != ']') {
- if (fname[i] == '.' || fname[i] == '[') {
- last_sep_pos = i++;
- continue;
- }
- if (fname[i++] != '-')
- continue;
- if (i > last_sep_pos + 2 || (i < len &&
- (fname[i] != '.') && fname[i] != ']')
- )
- continue;
- /* have separator followed by -. or -] */
- return true;
- }
- return false;
- }
-
- /* Answer the string to be used for combining a directory/device prefix */
- /* with a base file name. The prefix directory/device is examined to */
- /* determine if a separator is needed and may return an empty string */
- const char *
- gp_file_name_concat_string(const char *prefix, uint plen)
- {
- /* Full VAX/VMS paths are of the form:
-
- * device:[root.][directory.subdirectory]filename.extension;version
- * logical:filename.extension;version
- *
- * Roots are fairly rare and associated typically with rooted logical
- * names.
- *
- * Examples:
- *
- * DUA1:[GHOSTSCRIPT]GHOST.PS;1
- * THOR_DEC:[DOOF.A.B.C.D]FILE.DAT;-3
- * LOG:GHOST.PS (LOG is a logical defined as DUA1:[GHOSTSCRIPT])
- * LOG:DOOF.DAT (LOG is defined as DUA1, current directory is
- * is used as the directory spec.)
- *
- */
- if (plen > 0)
- switch (prefix[plen - 1]) {
- case ':':
- case ']':
- return "";
- };
- return ":";
- }
- #endif
-
/* ------ Wild card file search procedures ------ */
--- 264,267 ----
*** f:\casper\HEAD\gs\src\icontext.c Wed Mar 12 15:22:23 2003
--- files\gs\src\icontext.c Tue Aug 19 15:27:58 2003
***************
*** 148,155 ****
pcst->scanner_options = 0;
pcst->LockFilePermissions = false;
- #if NEW_COMBINE_PATH
pcst->starting_arg_file = false;
- #endif
- pcst->filearg = NULL;
/* The initial stdio values are bogus.... */
make_file(&pcst->stdio[0], a_readonly | avm_invalid_file_entry, 1,
--- 148,152 ----
*** f:\casper\HEAD\gs\src\icstate.h Wed Mar 12 15:22:23 2003
--- files\gs\src\icstate.h Tue Aug 19 15:27:50 2003
***************
*** 51,60 ****
int scanner_options; /* derived from userparams */
bool LockFilePermissions; /* accessed from userparams */
- #if NEW_COMBINE_PATH
bool starting_arg_file; /* starting a file specified in command line. */
- #else
- char *filearg; /* C string of the file being run */
- /* (allocated on the C heap, no gc needed) */
- #endif
ref stdio[3]; /* t_file */
/* Put the stacks at the end to minimize other offsets. */
--- 51,55 ----
*** f:\casper\HEAD\gs\src\imainarg.c Thu Apr 17 14:52:32 2003
--- files\gs\src\imainarg.c Tue Aug 19 15:26:51 2003
***************
*** 691,697 ****
if (filearg == NULL)
return e_Fatal;
- #if !NEW_COMBINE_PATH
- minst->i_ctx_p->filearg = filearg; /* allow reading this file if SAFER set */
- #endif
if (minst->run_buffer_size) {
/* Run file with run_string. */
--- 691,694 ----
***************
*** 763,773 ****
esc_strcat(line, arg);
strcat(line, post);
- #if NEW_COMBINE_PATH
minst->i_ctx_p->starting_arg_file = true;
- #endif
code = run_string(minst, line, options);
- #if NEW_COMBINE_PATH
minst->i_ctx_p->starting_arg_file = false;
- #endif
return code;
}
--- 760,766 ----
*** f:\casper\HEAD\gs\src\zfile.c Tue Aug 19 14:33:13 2003
--- files\gs\src\zfile.c Tue Aug 19 15:28:25 2003
***************
*** 151,160 ****
/* an empty string (first character == 0) if '\' character is */
/* recognized as a file name separator as on DOS & Windows */
- #if !NEW_COMBINE_PATH
- bool use_windows_pathsep = *gp_file_name_concat_string("\\", 1) == '\0';
- bool fname_bare = !gp_pathstring_not_bare(fname, len);
- const char *sep_string = NULL;
- int cwd_len = 0, sep_len = 0;
- #else
const char *win_sep2 = "\\";
bool use_windows_pathsep = (gs_file_name_check_separator(win_sep2, 1, win_sep2) == 1);
--- 151,154 ----
***************
*** 162,176 ****
/* Assuming a reduced file name. */
- #endif
if (dict_find_string(&(i_ctx_p->userparams), permitgroup, &permitlist) <= 0)
return 0; /* if Permissions not found, just allow access */
- #if !NEW_COMBINE_PATH
- if (fname_bare) {
- cwd_len = strlen(gp_current_directory_name);
- sep_string = gp_file_name_concat_string(gp_current_directory_name, cwd_len);
- sep_len = strlen(sep_string);
- }
- #endif
for (i=0; i<r_size(permitlist); i++) {
--- 156,162 ----
***************
*** 189,193 ****
permstr = permitstring.value.bytes;
permlen = r_size(&permitstring);
- #if NEW_COMBINE_PATH
/*
* Check if any file name is permitted with "*".
--- 175,178 ----
***************
*** 213,251 ****
* 'fname' has no "./" because it is reduced.
*/
- #endif
if (string_match( (const unsigned char*) fname, len,
permstr + cwd_len, permlen - cwd_len,
! use_windows_pathsep ? &win_filename_params : NULL)
! ) {
! #if !NEW_COMBINE_PATH
! /*
! * We can't know where we will get to if we reference the parent
! * directory, so don't allow access if LockFilePermissions is true
! * unless the Permission string starts with '*' (anywhere).
! */
! if (i_ctx_p->LockFilePermissions &&
! gp_file_name_references_parent(fname, len) &&
! permstr[0] != '*')
! continue; /* disregard this match and keep trying */
! else
! return 0; /* success */
! #else
return 0; /* success */
- #endif
- }
- #if !NEW_COMBINE_PATH
- /* fname is a bare name meaning it will default to the current
- * directory. Check to see if the current permitted path is the
- * platform's current directory, and if so, succeed.
- */
- if (fname_bare &&
- (permlen >= cwd_len + sep_len + 1) &&
- (bytes_compare(permstr, cwd_len,
- (const byte *)gp_current_directory_name, cwd_len) == 0) &&
- (bytes_compare(permstr + cwd_len, sep_len,
- (const byte *)sep_string, sep_len) == 0) &&
- (permstr[cwd_len + sep_len] == '*'))
- return 0; /* permitstring was CWD + sep + * */
- #endif
}
/* not found */
--- 198,205 ----
* 'fname' has no "./" because it is reduced.
*/
if (string_match( (const unsigned char*) fname, len,
permstr + cwd_len, permlen - cwd_len,
! use_windows_pathsep ? &win_filename_params : NULL))
return 0; /* success */
}
/* not found */
***************
*** 259,263 ****
const char *permitgroup)
{
- #if NEW_COMBINE_PATH
char fname_reduced[gp_file_name_sizeof];
uint rlen = sizeof(fname_reduced);
--- 213,216 ----
***************
*** 266,272 ****
return e_invalidaccess; /* fail if we couldn't reduce */
return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup);
- #else
- return check_file_permissions_reduced(i_ctx_p, fname, len, permitgroup);
- #endif
}
--- 219,222 ----
***************
*** 622,643 ****
}
- #if !NEW_COMBINE_PATH
- /* <dir> .filenamedirseparator <string> */
- private int
- zfilenamedirseparator(i_ctx_t *i_ctx_p)
- {
- os_ptr op = osp;
- const char *sepr;
-
- check_read_type(*op, t_string);
- sepr =
- gp_file_name_concat_string((const char *)op->value.const_bytes,
- r_size(op));
- make_const_string(op, avm_foreign | a_readonly,
- strlen(sepr), (const byte *)sepr);
- return 0;
- }
- #endif
-
/* - .filenamelistseparator <string> */
private int
--- 572,575 ----
***************
*** 700,723 ****
ref fref;
- # if !NEW_COMBINE_PATH
- /* Skip checks if this file name came from the command line. */
- if (i_ctx_p->LockFilePermissions &&
- (i_ctx_p->filearg == NULL ||
- bytes_compare(op->value.bytes, r_size(op),
- (const byte *)i_ctx_p->filearg,
- strlen( (const char*) i_ctx_p->filearg)) != 0)
- ) {
- /* Check to see if this file is allowed */
- /* Possibly we should allow access to parent directories if */
- /* PermitFileReading includes (*), but this is unlikely if */
- /* we are locked (and we checked LockFilePerminssions above).*/
- if (gp_file_name_references_parent(pname.fname, pname.len) ||
- (gp_pathstring_not_bare(pname.fname, pname.len) &&
- check_file_permissions(i_ctx_p, pname.fname, pname.len,
- "PermitFileReading") < 0)
- )
- return_error(e_invalidfileaccess);
- }
- # endif
code = lib_file_open(i_ctx_p, pname.fname, pname.len, cname, MAX_CNAME,
&clen, &fref, imemory);
--- 632,635 ----
***************
*** 829,845 ****
}
- #if !NEW_COMBINE_PATH
- /* <string> .pathstring_not_bare <bool> */
- private int
- zpathstring_not_bare(i_ctx_t *i_ctx_p)
- {
- os_ptr op = osp;
- check_type(*op, t_string);
- make_bool(op, gp_pathstring_not_bare((char *)op->value.bytes, r_size(op)));
- return 0;
- }
- #endif
-
-
/* ------ Initialization procedure ------ */
--- 741,744 ----
***************
*** 850,856 ****
{"2file", zfile},
{"3filenameforall", zfilenameforall},
- #if !NEW_COMBINE_PATH
- {"1.filenamedirseparator", zfilenamedirseparator},
- #endif
{"0.filenamelistseparator", zfilenamelistseparator},
{"1.filenamesplit", zfilenamesplit},
--- 749,752 ----
***************
*** 859,865 ****
{"1status", zstatus},
{"2.tempfile", ztempfile},
- #if !NEW_COMBINE_PATH
- {"2.pathstring_not_bare", zpathstring_not_bare},
- #endif
/* Internal operators */
{"0%file_continue", file_continue},
--- 755,758 ----
***************
*** 999,1004 ****
}
- #if NEW_COMBINE_PATH
-
private gp_file_name_combine_result
gp_file_name_combine_patch(const char *prefix, uint plen, const char *fname, uint flen,
--- 892,895 ----
***************
*** 1008,1034 ****
}
- #else
-
- private gp_file_name_combine_result
- gp_file_name_combine_patch(const char *prefix, uint plen, const char *fname, uint flen,
- bool no_sibling, char *buffer, uint *blen)
- {
- /* This is a stub. */
- /* It will be replaced with a more intelligent code. */
- const char *sep = gp_file_name_concat_string(prefix, plen);
- uint slen = strlen(sep);
-
- if (plen + flen + slen + 1 > *blen)
- return gp_combine_small_buffer;
- memcpy(buffer, prefix, plen);
- memcpy(buffer + plen, sep, slen);
- memcpy(buffer + plen + slen, fname, flen);
- *blen = plen + slen + flen;
- buffer[*blen] = 0;
- return gp_combine_success;
- }
-
- #endif /* NEW_COMBINE_PATH */
-
/* Prepare a stream with a file name. */
/* Return 0 if successful, error code if not. */
--- 899,902 ----
***************
*** 1076,1088 ****
if (i_ctx_p == NULL)
return 0;
- #if !NEW_COMBINE_PATH
- /* Skip checks if this file name came from the command line. */
- if (!i_ctx_p->LockFilePermissions ||
- (i_ctx_p->filearg != NULL &&
- bytes_compare((const byte *)fname, flen,
- (const byte *)i_ctx_p->filearg,
- strlen( (const char*)i_ctx_p->filearg) ) == 0))
- return 0;
- #endif
if (check_file_permissions_reduced(i_ctx_p, fname, flen, "PermitFileReading") < 0)
return_error(e_invalidfileaccess);
--- 944,947 ----
***************
*** 1101,1105 ****
bool search_with_combine = false;
- #if NEW_COMBINE_PATH
if (i_ctx_p != NULL) {
starting_arg_file = i_ctx_p->starting_arg_file;
--- 960,963 ----
***************
*** 1107,1113 ****
} else
starting_arg_file = true;
- #endif
-
- #if NEW_COMBINE_PATH
if (gp_file_name_is_absolute(fname, flen)) {
search_with_no_combine = true;
--- 965,968 ----
***************
*** 1117,1142 ****
search_with_combine = true;
}
- #else
- if (gp_pathstring_not_bare(fname, flen)) {
- search_with_no_combine = true;
- search_with_combine = false;
- } else {
- search_with_no_combine = false;
- search_with_combine = true;
- }
- #endif
if (search_with_no_combine) {
uint blen1 = blen;
- #if NEW_COMBINE_PATH
if (gp_file_name_reduce(fname, flen, buffer, &blen1) != gp_combine_success)
goto skip;
- #else
- if (flen + 1 > blen)
- return 0;
- memcpy(buffer, fname, flen);
- buffer[flen] = 0;
- blen1 = flen;
- #endif
if (iodev->procs.fopen(iodev, buffer, fmode, file,
buffer, blen) == 0) {
--- 972,980 ----
***************
*** 1149,1155 ****
} else
*file = NULL;
- #if NEW_COMBINE_PATH
skip:;
- #endif
}
if (search_with_combine) {
--- 987,991 ----
*** f:\casper\HEAD\gs\src\zfile1.c Fri Mar 21 13:17:29 2003
--- files\gs\src\zfile1.c Tue Aug 19 15:26:51 2003
***************
*** 66,70 ****
}
- #if NEW_COMBINE_PATH
/* This is compiled conditionally to let PS library to know
* whether it works with the new gp_combine_file_name.
--- 66,69 ----
***************
*** 117,126 ****
}
- #endif
-
const op_def zfile1_op_defs[] =
{
{"0.file_name_combine", zfile_name_combine},
- #if NEW_COMBINE_PATH
{"0.file_name_is_absolute", zfile_name_is_absolute},
{"0.file_name_separator", zfile_name_separator},
--- 116,122 ----
***************
*** 128,132 ****
{"0.file_name_current", zfile_name_current},
{"0.file_name_parent", zfile_name_parent},
- #endif
op_def_end(0)
};
--- 124,127 ----