[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1900-ge1b7dbc

[email protected] (Julian Smith) Tue, 19 Nov 2019 17:12:44 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  e1b7dbc95945ef2afa38faeebfda56830f2762ab (commit)
       via  e93430d762400247cdc4550be403a1f7c291112d (commit)
       via  bb2c2fbbc96b1f2de8e454ecb2adf3e58ddb52c3 (commit)
       via  a4c44cc7579ab80a1d49d721fad48e1ed9bbe976 (commit)
      from  f804ebfa526bd36a808319225488fe9de416f350 (commit)

----------------------------------------------------------------------
commit e1b7dbc95945ef2afa38faeebfda56830f2762ab
Author: Julian Smith <[email protected]>
Date:   Tue Nov 19 16:40:16 2019 +0000

    Coverity 350182: check for error before dereferencing ptr from gs_cspace_build_ICC().
    
    This allows us to remove the check for pcs == NULL after pcs has already been
    dereferenced, which was the coverity issue.
    
    Also fixed gs_cspace_build_ICC() to return gs_error_VMerror if
    gs_cspace_alloc() fails - was returning zero with *ppcspace out-param set to
    NULL. Have checked that all callers don't rely on the out-param being NULL to
    indicate error. Though some of them make no checks at all.

diff --git a/base/gdevp14.c b/base/gdevp14.c
index cdbeafd..de3f9ca 100644
--- a/base/gdevp14.c
+++ b/base/gdevp14.c
@@ -2460,8 +2460,6 @@ pdf14_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
     rowstride = buf->rowstride;
 
     code = gs_cspace_build_ICC(&pcs, NULL, pgs->memory);
-    if (pcs == NULL)
-        return_error(gs_error_VMerror);
     if (code < 0)
         return code;
     /* Need to set this to avoid color management during the image color render
@@ -8640,6 +8638,8 @@ pdf14_clist_create_compositor(gx_device	* dev, gx_device ** pcdev,
              * Set color space in preparation for sending an image.
              */
             code = gs_cspace_build_ICC(&pcs, NULL, pgs->memory);
+            if (code < 0)
+                goto put_accum_error;
 
             /* Need to set this to avoid color management during the
                image color render operation.  Exception is for the special case
@@ -8648,10 +8648,8 @@ pdf14_clist_create_compositor(gx_device	* dev, gx_device ** pcdev,
                here as we should have set the profile for the pdf14 device to RGB
                and the target will be CIELAB */
             code = dev_proc(dev, get_profile)(dev,  &dev_profile);
-            if (code < 0) {
-                rc_decrement_only_cs(pcs, "pdf14_put_image");
-                return code;
-            }
+            if (code < 0)
+                goto put_accum_error;
             gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile,
                                   &(pcs->cmm_icc_profile_data), &render_cond);
             /* pcs takes a reference to the profile data it just retrieved. */
@@ -8684,7 +8682,7 @@ pdf14_clist_create_compositor(gx_device	* dev, gx_device ** pcdev,
                    sizeof(gs_separation_map));
             target_devn_params->pdf14_separations = tdev->devn_params.pdf14_separations;
         }
-        if (linebuf == NULL || pcs == NULL) {
+        if (linebuf == NULL) {
             code = gs_error_VMerror;
             goto put_accum_error;
         }
diff --git a/base/gsicc.c b/base/gsicc.c
index 5095d4f..4f26eda 100644
--- a/base/gsicc.c
+++ b/base/gsicc.c
@@ -623,6 +623,9 @@ gs_cspace_build_ICC(
     gs_memory_t *       pmem )
 {
     gs_color_space *pcspace = gs_cspace_alloc(pmem, &gs_color_space_type_ICC);
+    if (!pcspace) {
+        return_error(gs_error_VMerror);
+    }
     *ppcspace = pcspace;
 
     return 0;

----------------------------------------------------------------------
commit e93430d762400247cdc4550be403a1f7c291112d
Author: Julian Smith <[email protected]>
Date:   Tue Nov 19 16:07:23 2019 +0000

    Coverity 350180: change gp_fmode_binary_suffix from char[] to char*.
    
    Am hoping this will persuade Coverity that it is zero-terminated and not
    zero-length, and thus safe to pass to strncat().

diff --git a/base/gp.h b/base/gp.h
index 5e5d2d2..7ea0b90 100644
--- a/base/gp.h
+++ b/base/gp.h
@@ -388,7 +388,7 @@ extern const char gp_current_directory_name[];
 /* Define the string to be concatenated with the file mode */
 /* for opening files without end-of-line conversion. */
 /* This is always either "" or "b". */
-extern const char gp_fmode_binary_suffix[];
+extern const char* gp_fmode_binary_suffix;
 
 /* Define the file modes for binary reading or writing. */
 /* (This is just a convenience: they are "r" or "w" + the suffix.) */
diff --git a/base/gp_dosfs.c b/base/gp_dosfs.c
index 47db3e4..cd14353 100644
--- a/base/gp_dosfs.c
+++ b/base/gp_dosfs.c
@@ -64,7 +64,7 @@ const char gp_file_name_list_separator = ';';
 
 /* Define the string to be concatenated with the file mode */
 /* for opening files without end-of-line conversion. */
-const char gp_fmode_binary_suffix[] = "b";
+const char* gp_fmode_binary_suffix = "b";
 
 /* Define the file modes for binary reading or writing. */
 const char gp_fmode_rb[] = "rb";
diff --git a/base/gp_ntfs.c b/base/gp_ntfs.c
index aaf183b..40bd148 100644
--- a/base/gp_ntfs.c
+++ b/base/gp_ntfs.c
@@ -75,7 +75,7 @@ const char gp_file_name_list_separator = ';';
 
 /* Define the string to be concatenated with the file mode */
 /* for opening files without end-of-line conversion. */
-const char gp_fmode_binary_suffix[] = "b";
+const char* gp_fmode_binary_suffix = "b";
 
 /* Define the file modes for binary reading or writing. */
 const char gp_fmode_rb[] = "rb";
diff --git a/base/gp_os2fs.c b/base/gp_os2fs.c
index f365f77..98c0bb9 100644
--- a/base/gp_os2fs.c
+++ b/base/gp_os2fs.c
@@ -64,7 +64,7 @@ const char gp_current_directory_name[] = ".";
 
 /* Define the string to be concatenated with the file mode */
 /* for opening files without end-of-line conversion. */
-const char gp_fmode_binary_suffix[] = "b";
+const char* gp_fmode_binary_suffix = "b";
 
 /* Define the file modes for binary reading or writing. */
 const char gp_fmode_rb[] = "rb";
diff --git a/base/gp_unifn.c b/base/gp_unifn.c
index cd62195..643f397 100644
--- a/base/gp_unifn.c
+++ b/base/gp_unifn.c
@@ -26,9 +26,9 @@ const char gp_file_name_list_separator = ':';
 /* Define the string to be concatenated with the file mode */
 /* for opening files without end-of-line conversion. */
 #if (defined(__MINGW32__) && __MINGW32__ == 1) || (defined(__CYGWIN__) && __CYGWIN__ == 1)
-const char gp_fmode_binary_suffix[] = "b";
+const char* gp_fmode_binary_suffix = "b";
 #else
-const char gp_fmode_binary_suffix[] = "";
+const char* gp_fmode_binary_suffix = "";
 #endif
 
 
diff --git a/base/gp_vms.c b/base/gp_vms.c
index 120f840..a69fb8e 100644
--- a/base/gp_vms.c
+++ b/base/gp_vms.c
@@ -212,7 +212,7 @@ const char gp_current_directory_name[] = "[]";
 
 /* Define the string to be concatenated with the file mode */
 /* for opening files without end-of-line conversion. */
-const char gp_fmode_binary_suffix[] = "";
+const char* gp_fmode_binary_suffix = "";
 
 /* Define the file modes for binary reading or writing. */
 const char gp_fmode_rb[] = "r";

----------------------------------------------------------------------
commit bb2c2fbbc96b1f2de8e454ecb2adf3e58ddb52c3
Author: Julian Smith <[email protected]>
Date:   Tue Nov 19 15:19:16 2019 +0000

    Coverity 341108: disable mktemp() SECURE_TEMP issue, as mkstemp() not available.

diff --git a/base/gp_unifs.c b/base/gp_unifs.c
index f0deeb2..75e49a1 100644
--- a/base/gp_unifs.c
+++ b/base/gp_unifs.c
@@ -128,6 +128,10 @@ gp_open_scratch_file_impl(const gs_memory_t *mem,
 	}
     }
 #else
+    /* Coverity thinks that any use of mktemp() is insecure. But if we reach
+    here then there is no mkstemp() alternative available, so there's not much
+    we can do. So we disable Coverity SECURE_TEMP explicitly. */
+    // coverity[SECURE_TEMP]
     mktemp(fname);
     fp = gp_fopentemp(fname, mode);
 #endif

----------------------------------------------------------------------
commit a4c44cc7579ab80a1d49d721fad48e1ed9bbe976
Author: Julian Smith <[email protected]>
Date:   Tue Nov 19 14:50:01 2019 +0000

    Coverity 323321: remove unused goto label and 'code' variable from template_mem_transform_pixel_region_render_landscape().
    
    The label and variable appear to have been copied from a similar function, but
    they are never used, and actually it looks like this fn can't fail.

diff --git a/base/gdevdrop.c b/base/gdevdrop.c
index b9a08d0..dcd3f65 100644
--- a/base/gdevdrop.c
+++ b/base/gdevdrop.c
@@ -1561,7 +1561,6 @@ template_mem_transform_pixel_region_render_landscape(gx_device *dev, mem_transfo
     int h = state->h;
     const byte *data = buffer[0] + data_x * spp;
     const byte *bufend = NULL;
-    int code = 0;
     const byte *run;
     int k;
     gx_color_value *conc = &cmapper->conc[0];
@@ -1648,15 +1647,9 @@ template_mem_transform_pixel_region_render_landscape(gx_device *dev, mem_transfo
                 }
             }
         }
-        if (code < 0)
-            goto err;
         data = run;
     }
     return 1;
-    /* Save position if error, in case we resume. */
-err:
-    buffer[0] = run;
-    return code;
 }
 
 static int


Summary of changes:
 base/gdevdrop.c |  7 -------
 base/gdevp14.c  | 12 +++++-------
 base/gp.h       |  2 +-
 base/gp_dosfs.c |  2 +-
 base/gp_ntfs.c  |  2 +-
 base/gp_os2fs.c |  2 +-
 base/gp_unifn.c |  4 ++--
 base/gp_unifs.c |  4 ++++
 base/gp_vms.c   |  2 +-
 base/gsicc.c    |  3 +++
 10 files changed, 19 insertions(+), 21 deletions(-)