summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2019-06-18 10:54:47 +0100
committerChris Liddell <chris.liddell@artifex.com>2019-06-18 10:54:47 +0100
commitd4d7d6948e41c2573b47645191dbb7e3877f0597 (patch)
tree3da95f548f457833e30c7003ab9f485a13b9fbc6
parent29da5d218dac7e0975c03a81982fdc33b5eba20d (diff)
downloadghostpdl-d4d7d6948e41c2573b47645191dbb7e3877f0597.tar.gz
Fix up some coverity issues, and other warnings
CIDs: 341120, 341119, 341118, 341117, 341116, 341115, 341114, 341113, 341112, 341111, 341110, 341109, 341108, 341107, 341106, 341105, 341104, 341103, 341102, 341101. Mostly examples of gp_fseek and sscanf ignoring return values.
-rw-r--r--base/gp_unifs.c12
-rw-r--r--base/mkromfs.c24
-rw-r--r--contrib/pcl3/eprn/pagecount.c8
-rw-r--r--contrib/pcl3/src/gdevpcl3.c2
-rw-r--r--contrib/pcl3/src/pclgen.c38
-rw-r--r--contrib/pcl3/src/pclgen.h2
-rw-r--r--devices/gdevdfax.c5
-rw-r--r--devices/gdevpsd.c12
-rw-r--r--devices/vector/gdevpdf.c2
-rw-r--r--devices/vector/gdevxps.c2
-rw-r--r--pcl/pl/pjparse.c12
-rw-r--r--pcl/pl/plmain.c2
-rw-r--r--psi/imainarg.c8
-rw-r--r--psi/iutil.c4
-rw-r--r--xps/xpszip.c10
15 files changed, 80 insertions, 63 deletions
diff --git a/base/gp_unifs.c b/base/gp_unifs.c
index c900326d4..f0deeb2a9 100644
--- a/base/gp_unifs.c
+++ b/base/gp_unifs.c
@@ -107,20 +107,20 @@ gp_open_scratch_file_impl(const gs_memory_t *mem,
/* save the old filename template in case mkstemp fails */
memcpy(ofname, fname, gp_file_name_sizeof);
-#ifdef HAVE_MKSTEMP64
+# ifdef HAVE_MKSTEMP64
file = mkstemp64(fname);
-#else
+# else
file = mkstemp(fname);
-#endif
+# endif
if (file < -1) {
emprintf1(mem, "**** Could not open temporary file %s\n", ofname);
return NULL;
}
-#if defined(O_LARGEFILE) && defined(__hpux)
+# if defined(O_LARGEFILE) && defined(__hpux)
fcntl(file, F_SETFD, fcntl(file, F_GETFD) | O_LARGEFILE);
-#else
+# else
/* Fixme : what to do with b64 and 32-bit mkstemp? Unimplemented. */
-#endif
+# endif
fp = fdopen(file, mode);
if (fp == NULL) {
diff --git a/base/mkromfs.c b/base/mkromfs.c
index ff18062b8..bd61f489e 100644
--- a/base/mkromfs.c
+++ b/base/mkromfs.c
@@ -615,8 +615,8 @@ typedef struct {
int outmax;
int buffercopy;
int wasascii;
- char *bufferin;
- char *bufferout;
+ unsigned char *bufferin;
+ unsigned char *bufferout;
psc_getc *pgetc;
psc_ungetc *unpgetc;
psc_feof *peof;
@@ -1026,7 +1026,7 @@ static int pscompact_isname(pscompstate *psc, int *i)
if (psc->bufferin[0] == '/')
off = 1;
for (n = 0; n < sizeof(pscompact_names)/sizeof(char *); n++) {
- if (strncmp(pscompact_names[n], &psc->bufferin[off], psc->inpos-off) == 0) {
+ if (strncmp(pscompact_names[n], (const char *)&psc->bufferin[off], psc->inpos-off) == 0) {
/* Match! */
if (off)
*i = -1-n;
@@ -1048,7 +1048,7 @@ static int pscompact_isint(pscompstate *psc, int *i)
if (pos >= psc->inpos)
return 0;
if ((psc->inpos > pos+3) &&
- (strncmp(&psc->bufferin[pos], "16#", 3) == 0)) {
+ (strncmp((const char *)&psc->bufferin[pos], "16#", 3) == 0)) {
/* hex */
int v = 0;
pos += 3;
@@ -1080,12 +1080,12 @@ static int pscompact_isint(pscompstate *psc, int *i)
psc->bufferin = realloc(psc->bufferin, psc->inmax);
}
psc->bufferin[psc->inpos] = 0;
- *i = atoi(psc->bufferin);
+ *i = atoi((const char *)psc->bufferin);
/* Check for 32bit overflow */
if (psc->inpos > 9) {
char *end;
- double d = strtod(psc->bufferin, &end);
+ double d = strtod((const char *)psc->bufferin, &end);
if (d != (double)(int)*i)
return 0;
}
@@ -1121,7 +1121,7 @@ static int pscompact_isfloat(pscompstate *psc, float *f)
psc->bufferin = realloc(psc->bufferin, psc->inmax);
}
psc->bufferin[psc->inpos] = 0;
- *f = atof(psc->bufferin);
+ *f = atof((const char *)psc->bufferin);
return 1;
}
@@ -1337,7 +1337,7 @@ static unsigned long pscompact_getcompactedblock(pscompstate *psc, unsigned char
}
}
if ((psc->inpos == 4) &&
- (strncmp(psc->bufferin, "true", 4) == 0)) {
+ (strncmp((const char *)psc->bufferin, "true", 4) == 0)) {
/* Encode as a 32 bit integer */
psc->bufferout[0] = 141;
psc->bufferout[1] = 1;
@@ -1350,7 +1350,7 @@ static unsigned long pscompact_getcompactedblock(pscompstate *psc, unsigned char
break;
}
if ((psc->inpos == 5) &&
- (strncmp(psc->bufferin, "false", 5) == 0)) {
+ (strncmp((const char *)psc->bufferin, "false", 5) == 0)) {
/* Encode as a 32 bit integer */
psc->bufferout[0] = 141;
psc->bufferout[1] = 0;
@@ -1568,7 +1568,7 @@ static unsigned long pscompact_getcompactedblock(pscompstate *psc, unsigned char
c = psc->pgetc(psc->file);
if ((c == 13) || (c == 10)) {
if ((psc->inpos >= 3) &&
- (strncmp(psc->bufferin, "END", 3) == 0)) {
+ (strncmp((const char *)psc->bufferin, "END", 3) == 0)) {
/* Special comment to retain */
pscompact_bufferatstart(psc, '%');
pscompact_buffer(psc, 10);
@@ -1576,7 +1576,7 @@ static unsigned long pscompact_getcompactedblock(pscompstate *psc, unsigned char
break;
}
if ((psc->inpos >= 7) &&
- (strncmp(psc->bufferin, "NAMESOK", 7) == 0)) {
+ (strncmp((const char *)psc->bufferin, "NAMESOK", 7) == 0)) {
psc->names = 1;
pscompact_bufferatstart(psc, '%');
pscompact_buffer(psc, 10);
@@ -1584,7 +1584,7 @@ static unsigned long pscompact_getcompactedblock(pscompstate *psc, unsigned char
break;
}
if ((psc->inpos >= 8) &&
- (strncmp(psc->bufferin, "BINARYOK", 8) == 0)) {
+ (strncmp((const char *)psc->bufferin, "BINARYOK", 8) == 0)) {
psc->binary = 1;
pscompact_bufferatstart(psc, '%');
pscompact_buffer(psc, 10);
diff --git a/contrib/pcl3/eprn/pagecount.c b/contrib/pcl3/eprn/pagecount.c
index f5ba13d6e..a635bd451 100644
--- a/contrib/pcl3/eprn/pagecount.c
+++ b/contrib/pcl3/eprn/pagecount.c
@@ -142,7 +142,7 @@ int pcf_getcount(const gs_memory_t *mem, const char *filename, unsigned long *co
gp_file *f;
/* Should we use a page count file? */
- if (filename == NULL || *filename == '\0') return 0;
+ if (filename == NULL || *filename == '\0' || count == NULL) return 0;
/* If the file does not exist, the page count is taken to be zero. */
if (access(filename, F_OK) != 0) {
@@ -153,7 +153,7 @@ int pcf_getcount(const gs_memory_t *mem, const char *filename, unsigned long *co
/* Open the file */
if ((f = gp_fopen(mem, filename, "r")) == NULL) {
errprintf(mem, ERRPREFIX "Cannot open page count file `%s': %s.\n",
- filename, strerror(gp_ferror(f)));
+ filename, strerror(errno));
return -1;
}
@@ -206,7 +206,7 @@ int pcf_inccount(const gs_memory_t *mem, const char *filename, unsigned long by)
*/
if ((f = gp_fopen(mem, filename, "a+")) == NULL) {
errprintf(mem, ERRPREFIX "Cannot open page count file `%s': %s.\n",
- filename, strerror(gp_ferror(f)));
+ filename, strerror(errno));
return 1;
}
@@ -239,7 +239,7 @@ int pcf_inccount(const gs_memory_t *mem, const char *filename, unsigned long by)
if (f1 == NULL) {
errprintf(mem, ERRPREFIX
"Error opening page count file `%s' a second time: %s.\n",
- filename, strerror(gp_ferror(f1)));
+ filename, strerror(errno));
rc = 1;
}
else {
diff --git a/contrib/pcl3/src/gdevpcl3.c b/contrib/pcl3/src/gdevpcl3.c
index c6e348520..7582c9bc7 100644
--- a/contrib/pcl3/src/gdevpcl3.c
+++ b/contrib/pcl3/src/gdevpcl3.c
@@ -1467,7 +1467,7 @@ static int pcl3_print_page(gx_device_printer *device, gp_file *out)
printer first */
if (gdev_prn_file_is_new(device) || !dev->configured ||
dev->configure_every_page) {
- guard(pcl3_init_file(out, &dev->file_data))
+ guard(pcl3_init_file(device->memory, out, &dev->file_data))
dev->configured = true;
}
diff --git a/contrib/pcl3/src/pclgen.c b/contrib/pcl3/src/pclgen.c
index 9426292d6..0670d8867 100644
--- a/contrib/pcl3/src/pclgen.c
+++ b/contrib/pcl3/src/pclgen.c
@@ -148,7 +148,7 @@ static void send_ERG(gp_file *out, pcl_Level level)
******************************************************************************/
-int pcl3_init_file(gp_file *out, pcl_FileData *data)
+int pcl3_init_file(gs_memory_t *mem, gp_file *out, pcl_FileData *data)
{
pcl_bool needs_CRD = (data->level == pcl_level_3plus_CRD_only);
/* Do we need Configure Raster Data? */
@@ -162,7 +162,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
invalid = (out == NULL || data == NULL);
if (invalid)
- errprintf(out->memory, ERRPREF "Null pointer passed to pcl3_init_file().\n");
+ errprintf(mem, ERRPREF "Null pointer passed to pcl3_init_file().\n");
else {
/* Palette und colorants */
switch(data->palette) {
@@ -175,7 +175,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
default: invalid = data->number_of_colorants <= 0;
}
if (invalid)
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"Palette specification and number of colorants are inconsistent.\n");
else {
if (data->colorant == NULL) colorant = data->colorant_array;
@@ -187,7 +187,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
for (j = 0; j < data->number_of_colorants; j++) {
if (colorant[j].hres <= 0 || colorant[j].vres <= 0) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"The resolution for colorant %d is not positive: %u x %u ppi.\n",
j, colorant[j].hres, colorant[j].vres);
}
@@ -199,7 +199,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
}
if (colorant[j].levels < 2 || 0xFFFF < colorant[j].levels) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF "The number of intensity levels for "
+ errprintf(mem, ERRPREF "The number of intensity levels for "
"colorant %d is %u instead of at least 2 and at most 65535.\n",
j, colorant[j].levels);
/* Actually, DJ6/8 p. 68 requires the levels to be in the range
@@ -235,21 +235,21 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
*/
if (colorant[j].vres % data->minvres != 0) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"The vertical resolution for colorant %d (%u ppi) is not a "
"multiple of the lowest vertical resolution (%u ppi).\n",
j, colorant[j].vres, data->minvres);
}
if (maxhres % colorant[j].hres != 0) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"The highest horizontal resolution (%u ppi) is not a multiple "
"of the horizontal resolution for colorant %d (%u ppi).\n",
maxhres, j, colorant[j].hres);
}
if (maxvres % colorant[j].vres != 0) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"The highest vertical resolution (%u ppi) is not a multiple "
"of the vertical resolution for colorant %d (%u ppi).\n",
maxvres, j, colorant[j].vres);
@@ -260,32 +260,32 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
if (needs_CRD && data->palette == pcl_RGB) {
invalid = TRUE;
if (data->level == pcl_level_3plus_CRD_only)
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"You can't use an RGB palette at the requested PCL level.\n");
else
- errprintf(out->memory, ERRPREF "The specified structure of resolutions and intensity "
+ errprintf(mem, ERRPREF "The specified structure of resolutions and intensity "
"levels is not possible with an RGB palette.\n");
}
if (needs_CRD && !pcl_has_CRD(data->level)) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF "The specified structure of resolutions and intensity "
+ errprintf(mem, ERRPREF "The specified structure of resolutions and intensity "
"levels is not possible at the requested PCL level.\n");
}
if (data->palette == pcl_any_palette) {
needs_CRD = TRUE;
if (!pcl_has_CRD(data->level)) {
invalid = TRUE;
- errprintf(out->memory, ERRPREF "The specified palette is not possible at the "
+ errprintf(mem, ERRPREF "The specified palette is not possible at the "
"requested PCL level.\n");
}
}
if (needs_CRD && (maxhres > 0xFFFF || maxvres > 0xFFFF)) {
- errprintf(out->memory, ERRPREF "Resolutions may be at most 65535 ppi when more than one "
+ errprintf(mem, ERRPREF "Resolutions may be at most 65535 ppi when more than one "
"resolution or more than two intensity levels are requested.\n");
invalid = TRUE;
}
if (data->order_CMYK && data->palette != pcl_CMYK) {
- errprintf(out->memory, ERRPREF
+ errprintf(mem, ERRPREF
"Ordering bit planes as CMYK instead of KCMY is only meaningful\n"
" for a CMYK palette.\n");
invalid = TRUE;
@@ -299,7 +299,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
exception of '"' (PJLTRM, with some corrections). */
while (*s != '\0' && (*s == '\t' || (32 <= *s && *s != '"'))) s++;
if (*s != '\0') {
- errprintf(out->memory,
+ errprintf(mem,
ERRPREF "Illegal character in PJL job name (code 0x%02X).\n", *s);
invalid = TRUE;
}
@@ -310,7 +310,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
There would also be a warning for an empty string but we treat that
case differently anyway (see below). */
if (strlen(data->PJL_job) > 80) {
- errprintf(out->memory, ERRPREF "PJL job name is too long (more than 80 characters).\n");
+ errprintf(mem, ERRPREF "PJL job name is too long (more than 80 characters).\n");
invalid = TRUE;
}
}
@@ -326,11 +326,11 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
if (is_letter(*s)) do s++; while (is_letter(*s) || is_digit(*s));
if (*data->PJL_language == '\0') {
- errprintf(out->memory, ERRPREF "Empty PJL language name.\n");
+ errprintf(mem, ERRPREF "Empty PJL language name.\n");
invalid = TRUE;
}
else if (*s != '\0') {
- errprintf(out->memory,
+ errprintf(mem,
ERRPREF "Illegal character in PJL language name (code 0x%02X).\n",
*s);
invalid = TRUE;
@@ -487,7 +487,7 @@ int pcl3_init_file(gp_file *out, pcl_FileData *data)
}
if (gp_ferror(out)) {
- errprintf(out->memory, ERRPREF "Unidentified system error while writing the output file.\n");
+ errprintf(mem, ERRPREF "Unidentified system error while writing the output file.\n");
return -1;
}
diff --git a/contrib/pcl3/src/pclgen.h b/contrib/pcl3/src/pclgen.h
index 8fa36c28f..d314d8d15 100644
--- a/contrib/pcl3/src/pclgen.h
+++ b/contrib/pcl3/src/pclgen.h
@@ -410,7 +410,7 @@ extern int pcl_compress(pcl_Compression method, const pcl_OctetString *in,
const pcl_OctetString *prev, pcl_OctetString *out);
/* File and page functions */
-extern int pcl3_init_file(gp_file *out, pcl_FileData *global);
+extern int pcl3_init_file(gs_memory_t *mem, gp_file *out, pcl_FileData *global);
extern int pcl3_begin_page(gp_file *out, pcl_FileData *global);
extern int pcl3_end_page(gp_file *out, pcl_FileData *global);
extern int pcl3_end_file(gp_file *out, pcl_FileData *global);
diff --git a/devices/gdevdfax.c b/devices/gdevdfax.c
index 905227db5..cfd2a6960 100644
--- a/devices/gdevdfax.c
+++ b/devices/gdevdfax.c
@@ -88,7 +88,10 @@ dfax_print_page(gx_device_printer *dev, gp_file *prn_stream)
{ hdr[45] = 0x40; hdr[29] = 1; } /* high res */
else
{ hdr[45] = hdr[29] = 0; } /* low res */
- gp_fseek(prn_stream, 0, SEEK_END);
+ code = gp_fseek(prn_stream, 0, SEEK_END);
+ if (code < 0)
+ return_error(gs_error_ioerror);
+
gp_fwrite(hdr, sizeof(hdr), 1, prn_stream);
/* Write the page */
diff --git a/devices/gdevpsd.c b/devices/gdevpsd.c
index 1babc604f..9212ff9dd 100644
--- a/devices/gdevpsd.c
+++ b/devices/gdevpsd.c
@@ -1294,10 +1294,18 @@ psd_write_image_data(psd_write_ctx *xc, gx_device_printer *pdev)
memset(sep_line,255,octets_per_line);
psd_write(xc, sep_line, octets_per_line);
}
- gp_fseek(xc->f, (xc->height-1) * octets_per_line, SEEK_CUR);
+ code = gp_fseek(xc->f, ((gs_offset_t)xc->height-1) * octets_per_line, SEEK_CUR);
+ if (code < 0) {
+ code = gs_note_error(gs_error_ioerror);
+ goto cleanup;
+ }
}
if (j < xc->height-1)
- gp_fseek(xc->f, -(num_comp * xc->height - 1) * octets_per_line, SEEK_CUR);
+ code = gp_fseek(xc->f, -((gs_offset_t)num_comp * xc->height - 1) * octets_per_line, SEEK_CUR);
+ if (code < 0) {
+ code = gs_note_error(gs_error_ioerror);
+ goto cleanup;
+ }
}
cleanup:
diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c
index e8deed46e..d1db9b36a 100644
--- a/devices/vector/gdevpdf.c
+++ b/devices/vector/gdevpdf.c
@@ -1587,7 +1587,7 @@ rewrite_object(gx_device_pdf *const pdev, pdf_linearisation_t *linear_params, in
target--;
}while (*target >= '0' && *target <= '9');
target++;
- sscanf(target, "%d 0 R", &ID);
+ (void)sscanf(target, "%d 0 R", &ID);
gp_fwrite(source, target - source, 1, linear_params->Lin_File.file);
gs_sprintf(Buf, "%d 0 R", pdev->ResourceUsage[ID].NewObjectNumber);
gp_fwrite(Buf, strlen(Buf), 1, linear_params->Lin_File.file);
diff --git a/devices/vector/gdevxps.c b/devices/vector/gdevxps.c
index 2ba26defb..71ca1f745 100644
--- a/devices/vector/gdevxps.c
+++ b/devices/vector/gdevxps.c
@@ -726,7 +726,7 @@ zip_close_archive_file(gx_device_xps *xps_dev, const char *filename)
return gs_throw_code(gs_error_Fatal);
crc = crc32(0L, Z_NULL, 0);
- gp_fseek(fp, 0, SEEK_SET);
+ gp_rewind(fp);
while (!gp_feof(fp)) {
nread = gp_fread(buf, 1, sizeof(buf), fp);
crc = crc32(crc, buf, nread);
diff --git a/pcl/pl/pjparse.c b/pcl/pl/pjparse.c
index 007dd461e..ab8f91394 100644
--- a/pcl/pl/pjparse.c
+++ b/pcl/pl/pjparse.c
@@ -1142,8 +1142,11 @@ pjl_get_named_resource_size(pjl_parser_state_t * pst, char *name)
if (fp == NULL)
return 0;
- gp_fseek(fp, 0L, SEEK_END);
- size = gp_ftell(fp);
+ size = gp_fseek(fp, 0L, SEEK_END);
+ if (size >= 0)
+ size = gp_ftell(fp);
+ else
+ size = 0;
gp_fclose(fp);
return size;
}
@@ -1159,8 +1162,9 @@ pjl_get_named_resource(pjl_parser_state * pst, char *name, byte * data)
if (fp == NULL)
return 0;
- gp_fseek(fp, 0L, SEEK_END);
- size = gp_ftell(fp);
+ size = gp_fseek(fp, 0L, SEEK_END);
+ if (size >= 0)
+ size = gp_ftell(fp);
gp_rewind(fp);
if (size < 0 || (size != gp_fread(data, 1, size, fp))) {
code = -1;
diff --git a/pcl/pl/plmain.c b/pcl/pl/plmain.c
index 1ce87ab61..067d459a5 100644
--- a/pcl/pl/plmain.c
+++ b/pcl/pl/plmain.c
@@ -1456,7 +1456,7 @@ pl_main_process_options(pl_main_instance_t * pmi, arg_list * pal,
if (*arg == 0)
gs_debug['#'] = 1;
else
- sscanf(arg, "%d", &pmi->error_report);
+ (void)sscanf(arg, "%d", &pmi->error_report);
break;
case 'f':
code = arg_next(pal, (const char **)&arg, pmi->memory);
diff --git a/psi/imainarg.c b/psi/imainarg.c
index 9739317eb..67bccec06 100644
--- a/psi/imainarg.c
+++ b/psi/imainarg.c
@@ -578,8 +578,6 @@ run_stdin:
if (code > 0)
code = argproc(minst, arg);
(void)gs_remove_control_path(minst->heap, gs_permit_file_reading, arg);
- if (code < 0)
- return code;
minst->run_buffer_size = bsize;
if (code < 0)
return code;
@@ -644,7 +642,7 @@ run_stdin:
long msize = 0;
gs_malloc_memory_t *rawheap = gs_malloc_wrapped_contents(minst->heap);
- sscanf((const char *)arg, "%ld", &msize);
+ (void)sscanf((const char *)arg, "%ld", &msize);
if (msize <= 0 || msize > max_long >> 10) {
outprintf(minst->heap, "-K<numK> must have 1 <= numK <= %ld\n",
max_long >> 10);
@@ -657,7 +655,7 @@ run_stdin:
{
unsigned msize = 0;
- sscanf((const char *)arg, "%u", &msize);
+ (void)sscanf((const char *)arg, "%u", &msize);
if (msize <= 0 || msize >= (max_uint >> 10)) {
outprintf(minst->heap, "-M must be between 1 and %d\n", (int)((max_uint >> 10) - 1));
return gs_error_Fatal;
@@ -669,7 +667,7 @@ run_stdin:
{
unsigned nsize = 0;
- sscanf((const char *)arg, "%d", &nsize);
+ (void)sscanf((const char *)arg, "%d", &nsize);
if (nsize < 2 || nsize > (max_uint >> 10)) {
outprintf(minst->heap, "-N must be between 2 and %d\n", (int)(max_uint >> 10));
return gs_error_Fatal;
diff --git a/psi/iutil.c b/psi/iutil.c
index 41b5cdf2f..55d0e5217 100644
--- a/psi/iutil.c
+++ b/psi/iutil.c
@@ -341,7 +341,7 @@ obj_cvp(const ref * op, byte * str, uint len, uint * prlen,
float scanned;
gs_sprintf(buf, "%g", value);
- sscanf(buf, "%f", &scanned);
+ (void)sscanf(buf, "%f", &scanned);
if (scanned != value)
gs_sprintf(buf, "%.9g", value);
ensure_dot(buf);
@@ -572,7 +572,7 @@ ensure_dot(char *buf)
char *pe = strchr(buf, 'e');
if (pe) {
int i;
- sscanf(pe + 1, "%d", &i);
+ (void)sscanf(pe + 1, "%d", &i);
/* MSVC .net 2005 express doesn't support "%+02d" */
if (i >= 0)
gs_sprintf(pe + 1, "+%02d", i);
diff --git a/xps/xpszip.c b/xps/xpszip.c
index 06dc9af4d..bf897dad1 100644
--- a/xps/xpszip.c
+++ b/xps/xpszip.c
@@ -302,7 +302,9 @@ xps_find_and_read_zip_dir(xps_context_t *ctx)
int i, n;
char buf[512];
- xps_fseek(ctx->file, 0, SEEK_END);
+ if (xps_fseek(ctx->file, 0, SEEK_END) < 0)
+ return gs_throw(-1, "seek to end failed.");
+
filesize = xps_ftell(ctx->file);
maxback = MIN(filesize, 0xFFFF + sizeof buf);
@@ -310,7 +312,8 @@ xps_find_and_read_zip_dir(xps_context_t *ctx)
while (back < maxback)
{
- xps_fseek(ctx->file, filesize - back, 0);
+ if (xps_fseek(ctx->file, filesize - back, 0) < 0)
+ return gs_throw1(gs_error_ioerror, "xps_fseek to %d failed.\n", filesize - back);
n = xps_fread(buf, 1, sizeof buf, ctx->file);
if (n < 0)
@@ -478,7 +481,8 @@ xps_read_dir_part(xps_context_t *ctx, const char *name)
if (!file)
break;
count ++;
- xps_fseek(file, 0, SEEK_END);
+ if (xps_fseek(file, 0, SEEK_END) < 0)
+ break;;
size += xps_ftell(file);
gp_fclose(file);
}