diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2019-03-07 18:03:00 +0000 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2019-05-29 09:39:36 +0100 |
commit | 9de16a6637b73e35f79d2d622de403b24e6502f2 (patch) | |
tree | bc6fba44e03e9caab75968fda94a0cea73caf5e3 /base/gstiffio.c | |
parent | 808021913baf763e07cc9eabc3716bfa507380ff (diff) | |
download | ghostpdl-9de16a6637b73e35f79d2d622de403b24e6502f2.tar.gz |
Move FILE * operations behind new gp_file * API.
(squash of commits from filesec branch)
Most of this commit is donkeywork conversions of calls from
FILE * -> gp_file *, fwrite -> gp_fwrite etc. Pretty much every
device is touched, along with the clist and parsing code.
The more interesting changes are within gp.h (where the actual
new API is defined), gpmisc.c (where the basic implementations
live), and the platform specific levels (gp_mswin.c, gp_unifs.c
etc where the platform specific implementations have been
tweaked/renamed).
File opening path validation
All file opening routines now call a central routine for
path validation.
This then consults new entries in gs_lib_ctx to see if validation
is enabled or not. If so, it validates the paths by seeing if
they match.
Simple C level functions for adding/removing/clearing paths, exposed
through the gsapi level.
Add 2 postscript operators for path control.
<name> <string> .addcontrolpath -
Add the given <string> (path) to the list of paths for
controlset <name>, where <name> can be:
/PermitFileReading
/PermitFileWriting
/PermitFileControl
(Anything else -> rangecheck)
- .activatepathcontrol -
Enable path control. At this point PS cannot make any
more changes, and all file access is checked.
Diffstat (limited to 'base/gstiffio.c')
-rw-r--r-- | base/gstiffio.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/base/gstiffio.c b/base/gstiffio.c index 1dbc9812c..e69ad145e 100644 --- a/base/gstiffio.c +++ b/base/gstiffio.c @@ -37,7 +37,7 @@ static const char tifs_msg_truncated[] = "\n*** Previous line has been truncated /* place to hold the data for our libtiff i/o hooks */ typedef struct tifs_io_private_t { - FILE *f; + gp_file *f; gx_device_printer *pdev; } tifs_io_private; @@ -68,7 +68,7 @@ gs_tifsReadProc(thandle_t fd, void* buf, size_t size) if ((size_t) size_io != size) { return (size_t) -1; } - return((size_t) fread (buf, 1, size_io, tiffio->f)); + return((size_t) gp_fread (buf, 1, size_io, tiffio->f)); } static size_t @@ -81,7 +81,7 @@ gs_tifsWriteProc(thandle_t fd, void* buf, size_t size) if ((size_t) size_io != size) { return (size_t) -1; } - written = (size_t) fwrite (buf, 1, size_io, tiffio->f); + written = (size_t) gp_fwrite (buf, 1, size_io, tiffio->f); return written; } @@ -94,10 +94,10 @@ gs_tifsSeekProc(thandle_t fd, uint64_t off, int whence) if ((uint64_t) off_io != off) { return (uint64_t) -1; /* this is really gross */ } - if (gp_fseek_64(tiffio->f , (gs_offset_t)off_io, whence) < 0) { + if (gp_fseek(tiffio->f , (gs_offset_t)off_io, whence) < 0) { return (uint64_t) -1; } - return (gp_ftell_64(tiffio->f)); + return (gp_ftell(tiffio->f)); } static int @@ -105,7 +105,7 @@ gs_tifsCloseProc(thandle_t fd) { tifs_io_private *tiffio = (tifs_io_private *)fd; gx_device_printer *pdev = tiffio->pdev; - int code = fclose(tiffio->f); + int code = gp_fclose(tiffio->f); gs_free(pdev->memory, tiffio, sizeof(tifs_io_private), 1, "gs_tifsCloseProc"); @@ -117,25 +117,25 @@ gs_tifsSizeProc(thandle_t fd) { tifs_io_private *tiffio = (tifs_io_private *)fd; uint64_t length; - gs_offset_t curpos = gp_ftell_64(tiffio->f); + gs_offset_t curpos = gp_ftell(tiffio->f); if (curpos < 0) { return(0); } - if (gp_fseek_64(tiffio->f, (gs_offset_t)0, SEEK_END) < 0) { + if (gp_fseek(tiffio->f, (gs_offset_t)0, SEEK_END) < 0) { return(0); } - length = (uint64_t)gp_ftell_64(tiffio->f); + length = (uint64_t)gp_ftell(tiffio->f); - if (gp_fseek_64(tiffio->f, curpos, SEEK_SET) < 0) { + if (gp_fseek(tiffio->f, curpos, SEEK_SET) < 0) { return(0); } return length; } TIFF * -tiff_from_filep(gx_device_printer *dev, const char *name, FILE *filep, int big_endian, bool usebigtiff) +tiff_from_filep(gx_device_printer *dev, const char *name, gp_file *filep, int big_endian, bool usebigtiff) { char mode[5] = "w"; int modelen = 1; |