[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1969-ga570a05

[email protected] (Robin Watts) Mon, 25 Nov 2019 20:05:51 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  a570a05622cb178c031db64711b412cf640038b2 (commit)
      from  fee6b609fbb8d1f0744f98ee3bf930c1fd733660 (commit)

----------------------------------------------------------------------
commit a570a05622cb178c031db64711b412cf640038b2
Author: Robin Watts <[email protected]>
Date:   Mon Nov 25 19:48:50 2019 +0000

    Coverity 350201, 350191: Add some notes to the code.
    
    Coverity spots that pdf14_fill_path checks for ppath being
    NULL in one branch, hence assumes that it can be NULL in all
    cases. Furthermore it spots that it is passed into
    gx_default_fill_path, which can in some circumstances, dereference
    it without checking it first.
    
    The reason for this is that fill_path can permissibly be called
    with a NULL path if we want to fill the given clipping path. This
    is only used for shadings and patterns, which is exactly the case
    checked for within gx_default_fill_path and pdf14_fill_path.
    
    We'll resolve this with a 'false positive' in Coverity, but have
    added the comments for the benefit of future readers.
    
    Coverity spots the same thing in pdf14_stroke_path, but there it
    really makes no sense for ppath to be NULL, so just eliminate the
    check.
    
    Credit to Julian Smith for the investigation on this.

diff --git a/base/gdevp14.c b/base/gdevp14.c
index 18d0283..1c534c3 100644
--- a/base/gdevp14.c
+++ b/base/gdevp14.c
@@ -3143,6 +3143,11 @@ pdf14_fill_path(gx_device *dev,	const gs_gstate *pgs,
     if (code >= 0) {
         new_pgs.trans_device = dev;
         new_pgs.has_transparency = true;
+        /* ppath can permissibly be NULL here, if we want to have a
+         * shading or a pattern fill the clipping path. This upsets
+         * coverity, which is not smart enough to realise that the
+         * validity of a NULL ppath depends on the type of pdcolor.
+         * We'll mark it as a false positive. */
         code = gx_default_fill_path(dev, &new_pgs, ppath, params, pdcolor, pcpath);
         new_pgs.trans_device = NULL;
         new_pgs.has_transparency = false;
@@ -3182,7 +3187,12 @@ pdf14_stroke_path(gx_device *dev, const	gs_gstate	*pgs,
             gx_cpath_outer_box(pcpath, &box);
         else
             (*dev_proc(dev, get_clipping_box)) (dev, &box);
-        if (ppath) {
+
+        /* For fill_path, we accept ppath == NULL to mean
+         * fill the entire clipping region. That makes no
+         * sense for stroke_path, hence ppath is always non
+         * NULL here. */
+        {
             gs_fixed_rect path_box;
             gs_fixed_point expansion;
 


Summary of changes:
 base/gdevp14.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)