[gs-code-review] CET 18-02c and 18-02d., makepattern error reporting

Leonardo leonardo at artifex.com
Fri Feb 23 12:20:06 PST 2007


I think it's fine to commit.

Leo.

----- Original Message ----- 
From: "Alex Cherepanov" <alexcher at quadnet.net>
To: "gs-code-review" <gs-code-review at ghostscript.com>
Sent: Friday, February 23, 2007 8:24 PM
Subject: [gs-code-review] CET 18-02c and 18-02d.,makepattern error reporting


> Use stricter validation of the pattern dictionary parameters to
> match CET 18-02c and 18-02d.
>
> DETAILS:
> In particular, don't accept the degenerative matrix, unnormalized,
> or empty bounding box. The difference in the operand stack
> is not yet fixed. Adobe doesn't restore operands of rectfill
> operator when an error happen in the PaintProc function but
> Ghostscript does.
>
> DIFFERENCES:
> No other CET differences, no comparefiles differences.
>
>


--------------------------------------------------------------------------------


> Index: gs/lib/gs_lev2.ps
> ===================================================================
> --- gs/lib/gs_lev2.ps (revision 7732)
> +++ gs/lib/gs_lev2.ps (working copy)
> @@ -852,7 +852,13 @@
> def
>
> /makepattern { % <proto_dict> <matrix> makepattern <pattern>
> -  //.patterntypes 2 .argindex /PatternType get get
> +  dup type /dicttype eq {
> +     % "<dict> makepattern" reports /typecheck on Adobe
> +     /makepattern .systemvar /typecheck signalerror
> +  } if
> +  //.patterntypes 2 .argindex /PatternType get .knownget not {
> +      /makepattern .systemvar /rangecheck signalerror
> +  } if
>   .currentglobal false .setglobal exch
>  % Stack: proto matrix global buildproc
>   3 index dup length 1 add dict .copydict
> Index: gs/src/zpcolor.c
> ===================================================================
> --- gs/src/zpcolor.c (revision 7732)
> +++ gs/src/zpcolor.c (working copy)
> @@ -89,20 +89,58 @@
>     gs_client_color cc_instance;
>     ref *pPaintProc;
>
> +    code = read_matrix(imemory, op, &mat);
> +    if (code < 0)
> +        return code;
>     check_type(*op1, t_dictionary);
>     check_dict_read(*op1);
>     gs_pattern1_init(&template);
> -    if ((code = read_matrix(imemory, op, &mat)) < 0 ||
> - (code = dict_uid_param(op1, &template.uid, 1, imemory, i_ctx_p)) != 1 ||
> - (code = dict_int_param(op1, "PaintType", 1, 2, 0, &template.PaintType)) 
> < 0 ||
> - (code = dict_int_param(op1, "TilingType", 1, 3, 0, 
> &template.TilingType)) < 0 ||
> - (code = dict_floats_param(imemory, op1, "BBox", 4, BBox, NULL)) < 0 ||
> - (code = dict_float_param(op1, "XStep", 0.0, &template.XStep)) != 0 ||
> - (code = dict_float_param(op1, "YStep", 0.0, &template.YStep)) != 0 ||
> - (code = dict_find_string(op1, "PaintProc", &pPaintProc)) <= 0
> - )
> - return_error((code < 0 ? code : e_rangecheck));
> +
> +    code = dict_uid_param(op1, &template.uid, 1, imemory, i_ctx_p);
> +    if (code < 0)
> +        return code;
> +    if (code != 1)
> +        return_error(e_rangecheck);
> +
> +    code = dict_int_param(op1, "PaintType", 1, 2, 0, 
> &template.PaintType);
> +    if (code < 0)
> +        return code;
> +
> +    code = dict_int_param(op1, "TilingType", 1, 3, 0, 
> &template.TilingType);
> +    if (code < 0)
> +        return code;
> +
> +    code = dict_floats_param(imemory, op1, "BBox", 4, BBox, NULL);
> +    if (code < 0)
> +        return code;
> +    if (code == 0)
> +       return_error(e_undefined);
> +
> +    code = dict_float_param(op1, "XStep", 0.0, &template.XStep);
> +    if (code < 0)
> +        return code;
> +    if (code == 1)
> +       return_error(e_undefined);
> +
> +    code = dict_float_param(op1, "YStep", 0.0, &template.YStep);
> +    if (code < 0)
> +        return code;
> +    if (code == 1)
> +       return_error(e_undefined);
> +
> +    code = dict_find_string(op1, "PaintProc", &pPaintProc);
> +    if (code < 0)
> +        return code;
> +    if (code == 0)
> +       return_error(e_undefined);
> +
>     check_proc(*pPaintProc);
> +
> +    if (mat.xx * mat.yy == mat.xy * mat.yx)
> +        return_error(e_undefinedresult);
> +    if (BBox[0] >= BBox[2] ||  BBox[1] >= BBox[3])
> +        return_error(e_rangecheck);
> +
>     template.BBox.p.x = BBox[0];
>     template.BBox.p.y = BBox[1];
>     template.BBox.q.x = BBox[2];
> Index: gs/lib/pdf_ops.ps
> ===================================================================
> --- gs/lib/pdf_ops.ps (revision 7732)
> +++ gs/lib/pdf_ops.ps (working copy)
> @@ -152,8 +152,8 @@
> /csdevcmyk [/DeviceCMYK] readonly def
> /cspattern [/Pattern] readonly def
> /nullpattern1 mark
> -   /PatternType 1 /PaintType 1 /TilingType 3 /BBox [0 0 0 0]
> -   /XStep 1 /YStep 1 /PaintProc { }
> +   /PatternType 1 /PaintType 1 /TilingType 3 /BBox [0 0 1 1]
> +   /XStep 1 /YStep 1 /PaintProc { pop } bind
> .dicttomark readonly def
> /nullpattern2 nullpattern1 dup length dict copy readonly def
>
> Index: gs/doc/pscet_status.txt
> ===================================================================
> --- gs/doc/pscet_status.txt (revision 7734)
> +++ gs/doc/pscet_status.txt (working copy)
> @@ -3712,11 +3712,12 @@
> 18-02B-9  AOK 18-02A-4 repeat
>  Fill rule is ok, shadings sharper in GS than Adobe. - Raph
>
> -18-02C-1  DIFF rangecheck vs. typecheck.
> -                undefined in cpsi not in GS. assign: Alex
> +18-02C-1  DIFF Partialy fixed by rev. 7735.
> +                Adobe doesn't restore operands of rectfill operator when
> +                an error happen in the PaintProc function but
> +                Ghostscript does. assign: Alex
>
> -18-02D-1  DIFF GS missing text. GS has different error messages.
> -                GS printing extra pattern mid-page. assign Alex
> +18-02D-1  OK  Fixed by rev. 7735. - Alex
>
> 18-02E-1  DIFF much of postscript dump missing in gs. assign Ray
>
>


--------------------------------------------------------------------------------


> _______________________________________________
> gs-code-review mailing list
> gs-code-review at ghostscript.com
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
> 



More information about the gs-code-review mailing list