diff options
author | Alex Cherepanov <alex.cherepanov@artifex.com> | 2012-04-23 23:44:18 -0400 |
---|---|---|
committer | Alex Cherepanov <alex.cherepanov@artifex.com> | 2012-04-23 23:44:18 -0400 |
commit | d561224d1495321d40012230abbcf835b298f557 (patch) | |
tree | 318769438dc76fd4b90b916880928d9c0234bce6 | |
parent | ec092a2630dd215a317f509ca283fc5cfb4e8b02 (diff) |
Bug 692983: Require EOD mark in ASCII85 string.
Make sure that ASCII85-encoded string is terminated with '~>' and
throw an error if it isn't. Old code accepted EOF as a valid
termination for a string token.
-rw-r--r-- | gs/base/sa85d.c | 5 | ||||
-rw-r--r-- | gs/base/sa85d.h | 9 | ||||
-rw-r--r-- | gs/psi/iscan.c | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/gs/base/sa85d.c b/gs/base/sa85d.c index 956d765fc..5c0b39e97 100644 --- a/gs/base/sa85d.c +++ b/gs/base/sa85d.c @@ -28,7 +28,8 @@ s_A85D_init(stream_state * st) { stream_A85D_state *const ss = (stream_A85D_state *) st; - return s_A85D_init_inline(ss); + s_A85D_init_inline(ss); + return 0; } /* Process a buffer */ @@ -164,6 +165,8 @@ s_A85D_process(stream_state * st, stream_cursor_read * pr, if (status == 0 && last) { if ((int)(wlimit - q) < ccount - 1) status = 1; + else if (ss->require_eod) + status = ERRC; else status = a85d_finish(ccount, word, pw); } diff --git a/gs/base/sa85d.h b/gs/base/sa85d.h index 0b9fc9eca..d22861041 100644 --- a/gs/base/sa85d.h +++ b/gs/base/sa85d.h @@ -24,6 +24,7 @@ typedef struct stream_A85D_state_s { int odd; /* # of odd digits */ ulong word; /* word being accumulated */ bool pdf_rules; /* hacks and tweaks for PDF */ + bool require_eod; /* ~> is required for tokens */ } stream_A85D_state; #define private_st_A85D_state() /* in sfilter2.c */\ @@ -32,7 +33,13 @@ typedef struct stream_A85D_state_s { /* We define the initialization procedure here, so that the scanner */ /* can avoid a procedure call. */ #define s_A85D_init_inline(ss)\ - ((ss)->min_left = 1, (ss)->word = 0, (ss)->odd = 0) + BEGIN \ + (ss)->min_left = 1; \ + (ss)->word = 0; \ + (ss)->odd = 0; \ + /* pdf_rules should not be initialized here */ \ + (ss)->require_eod=false; \ + END extern const stream_template s_A85D_template; #endif /* sa85d_INCLUDED */ diff --git a/gs/psi/iscan.c b/gs/psi/iscan.c index ad6116d20..ee99335e5 100644 --- a/gs/psi/iscan.c +++ b/gs/psi/iscan.c @@ -593,6 +593,7 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate) case '~': s_A85D_init_inline(&sstate.s_ss.a85d); sstate.s_ss.st.templat = &s_A85D_template; + sstate.s_ss.a85d.require_eod = true; goto str; } scan_putback(); |