diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2023-02-17 09:14:26 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2023-02-17 09:14:57 +0000 |
commit | a412aad1c19ef3bcf286a465f615bb5e3a9ad526 (patch) | |
tree | a859fb4a81b587ecb56f8b9853855c637c0482a9 /pdf | |
parent | 64d781de9217ba726b9047c81e4783625e619a02 (diff) | |
download | ghostpdl-a412aad1c19ef3bcf286a465f615bb5e3a9ad526.tar.gz |
GhostPDF - Dest names need not be C strings
Test file supplied in confidence by customer 820
The file has an Outlines entry where the /Dest has a name which is
in UTF16-BE. The code was dealing with strings as C strings, which
fails here because UTF16-BE text can contain NULLs.
In this commit; alter the comparison to use memcmp instead of strncmp
and pass the length of the PDF string as a parameter so that we do not
need to use strlen.
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_mark.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pdf/pdf_mark.c b/pdf/pdf_mark.c index 41f3f54f2..d39594681 100644 --- a/pdf/pdf_mark.c +++ b/pdf/pdf_mark.c @@ -753,9 +753,9 @@ error: return code; } -static int pdfi_get_name_from_node(pdf_context *ctx, pdf_dict *node, char *str, pdf_obj **Name, bool is_root) +static int pdfi_get_name_from_node(pdf_context *ctx, pdf_dict *node, char *str, int len, pdf_obj **Name, bool is_root) { - int i = 0, len = strlen(str), code = 0; + int i = 0, code = 0; pdf_string *StrKey = NULL; pdf_array *NamesArray = NULL; pdf_dict *Kid = NULL; @@ -798,7 +798,7 @@ static int pdfi_get_name_from_node(pdf_context *ctx, pdf_dict *node, char *str, if (code < 0) goto error; - if (StrKey->length == len && strncmp((const char *)StrKey->data, str, len) == 0) { + if (StrKey->length == len && memcmp((const char *)StrKey->data, str, len) == 0) { code = pdfi_array_get(ctx, NamesArray, (i * 2) + 1, (pdf_obj **)Name); goto error; } @@ -819,7 +819,7 @@ static int pdfi_get_name_from_node(pdf_context *ctx, pdf_dict *node, char *str, if (code < 0) goto error; - code = pdfi_get_name_from_node(ctx, Kid, str, Name, false); + code = pdfi_get_name_from_node(ctx, Kid, str, len, Name, false); pdfi_countdown(Kid); Kid = NULL; if (code == 0) @@ -873,7 +873,7 @@ static int pdfi_get_named_dest(pdf_context *ctx, pdf_obj *Named, pdf_obj **Dest) str[len] = 0; } - code = pdfi_get_name_from_node(ctx, Dests, str, Dest, true); + code = pdfi_get_name_from_node(ctx, Dests, str, len, Dest, true); error: if (pdfi_type_of(Named) == PDF_NAME) |