summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf/pdf_doc.c33
-rw-r--r--pdf/pdf_int.c19
2 files changed, 23 insertions, 29 deletions
diff --git a/pdf/pdf_doc.c b/pdf/pdf_doc.c
index 4b4d87d07..5bdb188d8 100644
--- a/pdf/pdf_doc.c
+++ b/pdf/pdf_doc.c
@@ -90,46 +90,23 @@ int pdfi_read_Root(pdf_context *ctx)
int pdfi_read_Info(pdf_context *ctx)
{
- pdf_obj *o, *o1;
+ pdf_dict *Info;
int code;
if (ctx->args.pdfdebug)
dmprintf(ctx->memory, "%% Reading Info dictionary\n");
- code = pdfi_dict_get(ctx, ctx->Trailer, "Info", &o1);
+ code = pdfi_dict_get_type(ctx, ctx->Trailer, "Info", PDF_DICT, (pdf_obj **)&Info);
if (code < 0)
return code;
- if (o1->type == PDF_INDIRECT) {
- code = pdfi_dereference(ctx, ((pdf_indirect_ref *)o1)->ref_object_num, ((pdf_indirect_ref *)o1)->ref_generation_num, &o);
- pdfi_countdown(o1);
- if (code < 0)
- return code;
-
- if (o->type != PDF_DICT) {
- pdfi_countdown(o);
- return_error(gs_error_typecheck);
- }
-
- code = pdfi_dict_put(ctx, ctx->Trailer, "Info", o);
- if (code < 0) {
- pdfi_countdown(o);
- return code;
- }
- o1 = o;
- } else {
- if (o1->type != PDF_DICT) {
- pdfi_countdown(o1);
- return_error(gs_error_typecheck);
- }
- }
-
if (ctx->args.pdfdebug)
dmprintf(ctx->memory, "\n");
- /* We don't pdfi_countdown(o1) now, because we've transferred our
+
+ /* We don't pdfi_countdown(Info) now, because we've transferred our
* reference to the pointer in the pdf_context structure.
*/
- ctx->Info = (pdf_dict *)o1;
+ ctx->Info = Info;
return 0;
}
diff --git a/pdf/pdf_int.c b/pdf/pdf_int.c
index bdad20bf4..33d871eae 100644
--- a/pdf/pdf_int.c
+++ b/pdf/pdf_int.c
@@ -468,6 +468,12 @@ static int pdfi_read_hexstring(pdf_context *ctx, pdf_c_stream *s, uint32_t indir
string->indirect_num = indirect_num;
string->indirect_gen = indirect_gen;
+ if (ctx->encryption.is_encrypted && ctx->encryption.decrypt_strings) {
+ code = pdfi_decrypt_string(ctx, string);
+ if (code < 0)
+ return code;
+ }
+
code = pdfi_push(ctx, (pdf_obj *)string);
if (code < 0)
pdfi_free_object((pdf_obj *)string);
@@ -1892,6 +1898,9 @@ pdfi_interpret_inner_content_c_string(pdf_context *ctx, char *content_string,
bool stoponerror, const char *desc)
{
uint32_t length = (uint32_t)strlen(content_string);
+ bool decrypt_strings;
+ int code;
+
/* Underlying buffer limit is uint32, so handle the extremely unlikely case that
* our string is too big.
@@ -1899,8 +1908,16 @@ pdfi_interpret_inner_content_c_string(pdf_context *ctx, char *content_string,
if (length != strlen(content_string))
return_error(gs_error_limitcheck);
- return pdfi_interpret_inner_content_buffer(ctx, (byte *)content_string, length,
+ /* Since this is a constructed string content, not part of the file, it can never
+ * be encrypted. So disable decryption during this call.
+ */
+ decrypt_strings = ctx->encryption.decrypt_strings;
+ ctx->encryption.decrypt_strings = false;
+ code = pdfi_interpret_inner_content_buffer(ctx, (byte *)content_string, length,
stream_dict, page_dict, stoponerror, desc);
+ ctx->encryption.decrypt_strings = decrypt_strings;
+
+ return code;
}
/* Interpret inner content from a string