diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2021-09-27 11:19:24 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2021-10-20 18:22:47 +0200 |
commit | cc6be9c3577168805ec34b2d396e63361012282b (patch) | |
tree | 7dc794b08a1a6a786d540516c623cb1eebfb1863 /base/gslibctx.c | |
parent | Import Ghostscript 9.54 (diff) | |
download | ghostscript-gpl-patches-cc6be9c3577168805ec34b2d396e63361012282b.tar.gz ghostscript-gpl-patches-cc6be9c3577168805ec34b2d396e63361012282b.tar.bz2 ghostscript-gpl-patches-cc6be9c3577168805ec34b2d396e63361012282b.zip |
Import Ghostscript 9.55ghostscript-9.55
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'base/gslibctx.c')
-rw-r--r-- | base/gslibctx.c | 69 |
1 files changed, 13 insertions, 56 deletions
diff --git a/base/gslibctx.c b/base/gslibctx.c index 6dfed6cd..318039fa 100644 --- a/base/gslibctx.c +++ b/base/gslibctx.c @@ -655,82 +655,39 @@ rewrite_percent_specifiers(char *s) int gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname) { - char *fp, f[gp_file_name_sizeof]; - const int pipe = 124; /* ASCII code for '|' */ - const int len = strlen(fname); - int i, code; + char f[gp_file_name_sizeof]; + int code; /* Be sure the string copy will fit */ - if (len >= gp_file_name_sizeof) + if (strlen(fname) >= gp_file_name_sizeof) return gs_error_rangecheck; strcpy(f, fname); - fp = f; /* Try to rewrite any %d (or similar) in the string */ rewrite_percent_specifiers(f); - for (i = 0; i < len; i++) { - if (f[i] == pipe) { - fp = &f[i + 1]; - /* Because we potentially have to check file permissions at two levels - for the output file (gx_device_open_output_file and the low level - fopen API, if we're using a pipe, we have to add both the full string, - (including the '|', and just the command to which we pipe - since at - the pipe_fopen(), the leading '|' has been stripped. - */ - code = gs_add_control_path(mem, gs_permit_file_writing, f); - if (code < 0) - return code; - code = gs_add_control_path(mem, gs_permit_file_control, f); - if (code < 0) - return code; - break; - } - if (!IS_WHITESPACE(f[i])) - break; - } - code = gs_add_control_path(mem, gs_permit_file_control, fp); + + code = gs_add_control_path(mem, gs_permit_file_control, f); if (code < 0) return code; - return gs_add_control_path(mem, gs_permit_file_writing, fp); + return gs_add_control_path(mem, gs_permit_file_writing, f); } int gs_remove_outputfile_control_path(gs_memory_t *mem, const char *fname) { - char *fp, f[gp_file_name_sizeof]; - const int pipe = 124; /* ASCII code for '|' */ - const int len = strlen(fname); - int i, code; + char f[gp_file_name_sizeof]; + int code; /* Be sure the string copy will fit */ - if (len >= gp_file_name_sizeof) + if (strlen(fname) >= gp_file_name_sizeof) return gs_error_rangecheck; strcpy(f, fname); - fp = f; /* Try to rewrite any %d (or similar) in the string */ - for (i = 0; i < len; i++) { - if (f[i] == pipe) { - fp = &f[i + 1]; - /* Because we potentially have to check file permissions at two levels - for the output file (gx_device_open_output_file and the low level - fopen API, if we're using a pipe, we have to add both the full string, - (including the '|', and just the command to which we pipe - since at - the pipe_fopen(), the leading '|' has been stripped. - */ - code = gs_remove_control_path(mem, gs_permit_file_writing, f); - if (code < 0) - return code; - code = gs_remove_control_path(mem, gs_permit_file_control, f); - if (code < 0) - return code; - break; - } - if (!IS_WHITESPACE(f[i])) - break; - } - code = gs_remove_control_path(mem, gs_permit_file_control, fp); + rewrite_percent_specifiers(f); + + code = gs_remove_control_path(mem, gs_permit_file_control, f); if (code < 0) return code; - return gs_remove_control_path(mem, gs_permit_file_writing, fp); + return gs_remove_control_path(mem, gs_permit_file_writing, f); } int |