diff options
author | Igor Melichev <igor.melichev@artifex.com> | 2005-04-25 12:28:49 +0000 |
---|---|---|
committer | Igor Melichev <igor.melichev@artifex.com> | 2005-04-25 12:28:49 +0000 |
commit | aa9199546a615ad2cd470f05cf5743466bf96abf (patch) | |
tree | 228cce72e84e5778558b12810c8a48f5c6eeecbe | |
parent | 8443031fe031c49f6edf473d2cc76bed134d6801 (diff) | |
download | ghostpdl-aa9199546a615ad2cd470f05cf5743466bf96abf.tar.gz |
Fix (pdfwrite) : Uninitialized variable when encrypting a string from a pdfmark.
DETAILS :
Bug 687809 "pdfwrite: A wrong encryption of bookmarks".
This bug may become another classic example,
which demonstrates a bad coding style.
The function s_PSSD_init incompletely performed the action,
which it is designed for. The reason is that the macro
s_PSSD_init_inline was made especially for optimizing
scan_token, and its name doesn't reflect its action.
When coded s_PSSD_init, its action was forgotten.
As a result we've got an indeterministic behavior.
This fix renames s_PSSD_init_inline into s_PSSD_partially_init_inline
for a better reflection of its action, completes s_PSSD_init,
and makes the letter be public for a regular initialization.
Particularly using it gdevpdfr.c to fix another indeterministic bug,
which persists since the repository was created.
EXPECTED DIFFERENCES :
None.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@5889 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/src/gdevpdfr.c | 2 | ||||
-rw-r--r-- | gs/src/iscan.c | 2 | ||||
-rw-r--r-- | gs/src/sstring.c | 5 | ||||
-rw-r--r-- | gs/src/sstring.h | 9 |
4 files changed, 12 insertions, 6 deletions
diff --git a/gs/src/gdevpdfr.c b/gs/src/gdevpdfr.c index 8509bfaaa..2daffb58c 100644 --- a/gs/src/gdevpdfr.c +++ b/gs/src/gdevpdfr.c @@ -309,7 +309,7 @@ pdf_scan_token(const byte **pscan, const byte * end, const byte **ptoken) stream_PSSD_state ss; int status; - s_PSSD_init_inline(&ss); + s_PSSD_init((stream_state *)&ss); r.ptr = p; /* skip the '(' */ r.limit = end - 1; w.limit = buf + sizeof(buf) - 1; diff --git a/gs/src/iscan.c b/gs/src/iscan.c index 192e55f77..5c85d08b8 100644 --- a/gs/src/iscan.c +++ b/gs/src/iscan.c @@ -593,7 +593,7 @@ scan_token(i_ctx_t *i_ctx_p, stream * s, ref * pref, scanner_state * pstate) sstate.s_ss.pssd.from_string = ((pstate->s_options & SCAN_FROM_STRING) != 0) && !scan_enable_level2; - s_PSSD_init_inline(&sstate.s_ss.pssd); + s_PSSD_partially_init_inline(&sstate.s_ss.pssd); sstate.s_ss.st.template = &s_PSSD_template; goto str; case '{': diff --git a/gs/src/sstring.c b/gs/src/sstring.c index c0b9945f9..ef32b2fa7 100644 --- a/gs/src/sstring.c +++ b/gs/src/sstring.c @@ -222,12 +222,13 @@ const stream_template s_PSSE_template = private_st_PSSD_state(); /* Initialize the state */ -private int +int s_PSSD_init(stream_state * st) { stream_PSSD_state *const ss = (stream_PSSD_state *) st; - return s_PSSD_init_inline(ss); + ss->from_string = false; + return s_PSSD_partially_init_inline(ss); } /* Process a buffer */ diff --git a/gs/src/sstring.h b/gs/src/sstring.h index 033ac56f3..84fcf1ebc 100644 --- a/gs/src/sstring.h +++ b/gs/src/sstring.h @@ -61,9 +61,14 @@ typedef struct stream_PSSD_state_s { #define private_st_PSSD_state() /* in sstring.c */\ gs_private_st_simple(st_PSSD_state, stream_PSSD_state,\ "PSStringDecode state") -/* We define the initialization procedure here, so that the scanner */ + +/* Initialize the state */ +int s_PSSD_init(stream_state * st); + +/* A special initialization procedure for the scanner */ /* can avoid a procedure call. */ -#define s_PSSD_init_inline(ss)\ +/* Note : it doesn't initialize ss->from_string. */ +#define s_PSSD_partially_init_inline(ss)\ ((ss)->depth = 0) extern const stream_template s_PSSD_template; |