summaryrefslogtreecommitdiff
path: root/xps
diff options
context:
space:
mode:
authorEthan Vrhel <ethanvrhel@gmail.com>2022-06-17 14:29:52 -0700
committerEthan Vrhel <ethanvrhel@gmail.com>2022-06-22 13:33:55 -0700
commitd8b93cd047055b855df0d7eb4c8b2c591ef71585 (patch)
treec9b57e54f5e8b357d13e21f705915d26181decf4 /xps
parent56c467bf2355c4d7989d6e0981f2adf638c7b6df (diff)
downloadghostpdl-d8b93cd047055b855df0d7eb4c8b2c591ef71585.tar.gz
Bug 705397 : XPS interpreter
Fixed buffer containing uninitialized data on return in xps_read_dir_part().
Diffstat (limited to 'xps')
-rw-r--r--xps/xpszip.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/xps/xpszip.c b/xps/xpszip.c
index 6a0762a27..e07e516c1 100644
--- a/xps/xpszip.c
+++ b/xps/xpszip.c
@@ -433,6 +433,7 @@ xps_read_dir_part(xps_context_t *ctx, const char *name)
xps_part_t *part;
gp_file *file;
int count, size, offset, i, n;
+ int seen_last = 0;
gs_strlcpy(buf, ctx->directory, sizeof buf);
gs_strlcat(buf, name, sizeof buf);
@@ -469,7 +470,7 @@ xps_read_dir_part(xps_context_t *ctx, const char *name)
/* Count the number of pieces and their total size */
count = 0;
size = 0;
- while (1)
+ while (!seen_last)
{
gs_snprintf(buf, sizeof(buf), "%s%s/[%d].piece", ctx->directory, name, count);
file = gp_fopen(ctx->memory, buf, "rb");
@@ -477,6 +478,7 @@ xps_read_dir_part(xps_context_t *ctx, const char *name)
{
gs_snprintf(buf, sizeof(buf), "%s%s/[%d].last.piece", ctx->directory, name, count);
file = gp_fopen(ctx->memory, buf, "rb");
+ seen_last = !!file;
}
if (!file)
break;
@@ -486,6 +488,11 @@ xps_read_dir_part(xps_context_t *ctx, const char *name)
size += xps_ftell(file);
gp_fclose(file);
}
+ if (!seen_last)
+ {
+ gs_throw1(-1, "cannot find all pieces for part '%s'", name);
+ return NULL;
+ }
/* Inflate the pieces */
if (count)