[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1869-g83c6e52

[email protected] (Julian Smith) Fri, 15 Nov 2019 17:07:06 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  83c6e520ee6eddeaa1e548e519eb1b42941e3153 (commit)
       via  76c088b2b5468c1551c4636dc9d20f5b1ea5da36 (commit)
       via  b51e2be557128054b0f1e8f6eb4c3b7de506cca2 (commit)
       via  dd95eb235f00a600f8b8b99b8929e597283fa96c (commit)
       via  95706a3ced4f1cfa50b2ea48f0095ed9423bafe5 (commit)
      from  5f24a32f0cc4513dfb9825900d561b3a6771b87c (commit)

----------------------------------------------------------------------
commit 83c6e520ee6eddeaa1e548e519eb1b42941e3153
Author: Julian Smith <[email protected]>
Date:   Fri Nov 15 12:32:50 2019 +0000

    Coverity 102206: use snprintf() to avoid unsafe strcpy() and strcat().

diff --git a/pcl/pl/pjparse.c b/pcl/pl/pjparse.c
index 72c1be7..1060caf 100644
--- a/pcl/pl/pjparse.c
+++ b/pcl/pl/pjparse.c
@@ -731,8 +731,7 @@ pjl_search_for_file(pjl_parser_state_t * pst, char *pathname, char *filename,
     struct stat stbuf;
 
     /* should check length */
-    strcpy(fontfilename, pathname);
-    strcat(fontfilename, "/*");
+    snprintf(fontfilename, sizeof(fontfilename), "%s/*", pathname);
     fe = gs_enumerate_files_init(pst->mem, fontfilename, strlen(fontfilename));
     if (fe) {
         do {

----------------------------------------------------------------------
commit 76c088b2b5468c1551c4636dc9d20f5b1ea5da36
Author: Julian Smith <[email protected]>
Date:   Fri Nov 15 12:24:36 2019 +0000

    Coverity 102205: cast ushort to final expression type (long) before bit-shift, to avoid sign extension.

diff --git a/pcl/pl/pllfont.c b/pcl/pl/pllfont.c
index d2fe927..4bf49d6 100644
--- a/pcl/pl/pllfont.c
+++ b/pcl/pl/pllfont.c
@@ -255,7 +255,7 @@ pl_fill_in_mt_font(gs_font_base * pfont, pl_font_t * plfont, ushort handle,
             pfont->FontBBox.p.x = pfont->FontBBox.p.y =
                 pfont->FontBBox.q.x = pfont->FontBBox.q.y = 0;
 
-            uid_set_UniqueID(&pfont->UID, unique_id | (handle << 16));
+            uid_set_UniqueID(&pfont->UID, unique_id | ( ((long) handle) << 16));
             pfont->encoding_index = 1;      /****** WRONG ******/
             pfont->nearest_encoding_index = 1;      /****** WRONG ******/
         }

----------------------------------------------------------------------
commit b51e2be557128054b0f1e8f6eb4c3b7de506cca2
Author: Julian Smith <[email protected]>
Date:   Fri Nov 15 11:49:17 2019 +0000

    Coverity 102204: cast byte to long to avoid possible sign extension.

diff --git a/pcl/pcl/pcwhtidx.c b/pcl/pcl/pcwhtidx.c
index 0f3141c..00ada33 100644
--- a/pcl/pcl/pcwhtidx.c
+++ b/pcl/pcl/pcwhtidx.c
@@ -217,7 +217,8 @@ pcl_cmap_map_raster(const pcl_cs_indexed_t * pindexed,
 
     /* allocate a new raster if necessary (pack scanlines) */
     if (must_copy) {
-        long nbytes = pin_pixinfo->size.x * pin_pixinfo->pix_depth;
+        /* Cast to long to avoid coverity warning about sign extension. */
+        long nbytes = (long) pin_pixinfo->size.x * pin_pixinfo->pix_depth;
 
         nbytes = ((nbytes + 7) / 8);
         pout_pixinfo->raster = nbytes;

----------------------------------------------------------------------
commit dd95eb235f00a600f8b8b99b8929e597283fa96c
Author: Julian Smith <[email protected]>
Date:   Fri Nov 15 11:30:34 2019 +0000

    Coverity 102189: removed less-than-zero comparison of unsigned.

diff --git a/pcl/pl/plfont.c b/pcl/pl/plfont.c
index 514c105..9982701 100644
--- a/pcl/pl/plfont.c
+++ b/pcl/pl/plfont.c
@@ -406,7 +406,7 @@ pl_glyph_name(gs_font * pfont, gs_glyph glyph, gs_const_string * pstr)
         }
         /* skip over the post header */
         numGlyphs = u16(postp + 32);
-        if (glyph < 0 || glyph > numGlyphs - 1) {
+        if (glyph > numGlyphs - 1) {
             if_debug1m('=', pfont->memory,
                        "[=]glyph index %lx out of range\n", glyph);
             return -1;
@@ -414,7 +414,7 @@ pl_glyph_name(gs_font * pfont, gs_glyph glyph, gs_const_string * pstr)
         /* glyph name index starts at post + 34 each entry is 2 bytes */
         glyph_name_index = u16(postp + 34 + (glyph * 2));
         /* this shouldn't happen */
-        if (glyph_name_index < 0 && glyph_name_index > 0x7fff)
+        if (glyph_name_index > 0x7fff)
             return -1;
         /* mac easy */
         if (glyph_name_index < 258) {

----------------------------------------------------------------------
commit 95706a3ced4f1cfa50b2ea48f0095ed9423bafe5
Author: Julian Smith <[email protected]>
Date:   Fri Nov 15 11:27:53 2019 +0000

    Coverity 102173: removed unnecessary comparisons against hpgl_rm_character.

diff --git a/pcl/pcl/pgdraw.c b/pcl/pcl/pgdraw.c
index 0a4baf3..9d17414 100644
--- a/pcl/pcl/pgdraw.c
+++ b/pcl/pcl/pgdraw.c
@@ -440,7 +440,7 @@ hpgl_set_graphics_line_attribute_state(hpgl_state_t * pgls,
      * is not documented PCLTRM.  Pen widths are maintained in
      * plotter units
      */
-    if (render_mode != hpgl_rm_character && pen_wid <= 14.0) {
+    if (pen_wid <= 14.0) {
         hpgl_call(gs_setlinejoin(pgls->pgs, gs_join_none));
         hpgl_call(gs_setlinecap(pgls->pgs, gs_cap_butt));
         hpgl_call(gs_setlinewidth(pgls->pgs, pen_wid));
@@ -450,7 +450,6 @@ hpgl_set_graphics_line_attribute_state(hpgl_state_t * pgls,
 
     switch (render_mode) {
 
-        case hpgl_rm_character:
         case hpgl_rm_polygon:
         case hpgl_rm_clip_and_fill_polygon:
             hpgl_call(gs_setlinejoin(pgls->pgs, gs_join_round));


Summary of changes:
 pcl/pcl/pcwhtidx.c | 3 ++-
 pcl/pcl/pgdraw.c   | 3 +--
 pcl/pl/pjparse.c   | 3 +--
 pcl/pl/plfont.c    | 4 ++--
 pcl/pl/pllfont.c   | 2 +-
 5 files changed, 7 insertions(+), 8 deletions(-)