Please apply the following patch, it is required for proper compilation
under gcc 4.1.  Gcc 4.1 will see wide use very soon, in fact some arches
require it, and Debian is seriously considering switching to gcc 4.1 for the
next stable version.

Without this patch, hpijs has to be compiled using --no-strict-aliasing.

BTW: the hunk that applies to prnt/hpijs/hpijs.cpp illustrates
beautifully(?!) the utter lack of untrusted input validation one can find in
hpijs.  I don't have time to add paranoia to hpijs, but please take this as
a request that someone dedicate paid time to fix that mess (and the big mess
with types and huge amount of typecasts, often dangerous and prone to
breakage on various arches).

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
? debian/patches/gcc-4.1-fixes
Index: prnt/hpijs/hpijs.cpp
===================================================================
RCS file: /cvsroot/pkg-hpijs/hplip/prnt/hpijs/hpijs.cpp,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 hpijs.cpp
--- prnt/hpijs/hpijs.cpp        1 Mar 2006 02:07:27 -0000       1.1.1.7
+++ prnt/hpijs/hpijs.cpp        11 May 2006 03:13:47 -0000
@@ -272,19 +272,19 @@
    }
    else if (!strcmp (key, "Quality:Quality"))
    {
-      pSS->Quality = strtol(svalue, &tail, 10);
+      pSS->Quality = (QUALITY_MODE) strtol(svalue, &tail, 10);
    }
    else if (!strcmp (key, "Quality:MediaType"))
    {
-      pSS->MediaType = strtol(svalue, &tail, 10);
+      pSS->MediaType = (MEDIATYPE) strtol(svalue, &tail, 10);
    }
    else if (!strcmp (key, "Quality:ColorMode"))
    {
-      pSS->ColorMode = strtol(svalue, &tail, 10);
+      pSS->ColorMode = (COLORMODE) strtol(svalue, &tail, 10);
    }
    else if (!strcmp (key, "Quality:PenSet"))
    {
-      pSS->PenSet = strtol(svalue, &tail, 10);
+      pSS->PenSet = (PEN_TYPE) strtol(svalue, &tail, 10);
    }
    else if (!strcmp (key, "Quality:FullBleed"))
    {
Index: prnt/hpijs/ljfastraster.cpp
===================================================================
RCS file: /cvsroot/pkg-hpijs/hplip/prnt/hpijs/ljfastraster.cpp,v
retrieving revision 1.5
diff -u -r1.5 ljfastraster.cpp
--- prnt/hpijs/ljfastraster.cpp 15 Mar 2006 03:45:33 -0000      1.5
+++ prnt/hpijs/ljfastraster.cpp 11 May 2006 03:13:47 -0000
@@ -1215,7 +1215,7 @@
 
                        m_compressedsize = 2 * inputsize * INDY_STRIP_HEIGHT;
             BOOL bRet = Compress (compressBuf, 
-                                  (uint32_t *) &m_compressedsize,
+                                  &m_compressedsize,
                                   pbyInputImageBuffer,
                                   inputsize,
                                   m_lCurrCDRasterRow,
Index: prnt/hpijs/ljfastraster.h
===================================================================
RCS file: /cvsroot/pkg-hpijs/hplip/prnt/hpijs/ljfastraster.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ljfastraster.h
--- prnt/hpijs/ljfastraster.h   25 Mar 2005 21:12:01 -0000      1.1.1.1
+++ prnt/hpijs/ljfastraster.h   11 May 2006 03:13:47 -0000
@@ -32,6 +32,7 @@
 #ifndef APDK_LJFASTRASTER_H
 #define APDK_LJFASTRASTER_H
 
+#include "global_types.h"
 
 APDK_BEGIN_NAMESPACE
 /*!
@@ -136,7 +137,7 @@
        long                m_lCurrBlockHeight;
     long                m_lPrinterRasterRow;           // Current printer 
raster row.
 
-       unsigned long       m_compressedsize;
+       uint32_t            m_compressedsize;
        BOOL                m_bCompressed;
        float               m_fRatio;
     HPUInt8             *pbySeedRow;
Index: prnt/hpijs/services.cpp
===================================================================
RCS file: /cvsroot/pkg-hpijs/hplip/prnt/hpijs/services.cpp,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 services.cpp
--- prnt/hpijs/services.cpp     1 Mar 2006 02:07:27 -0000       1.1.1.9
+++ prnt/hpijs/services.cpp     11 May 2006 03:13:47 -0000
@@ -270,9 +270,9 @@
        }
    }
 
-   Quality = 0;     /* normal */
-   MediaType = 0;   /* plain */
-   ColorMode = 2;   /* color */
+   Quality = QUALITY_NORMAL;
+   MediaType = MEDIA_PLAIN;
+   ColorMode = COLOR;
    PenSet = DUMMY_PEN;
    
    RastersOnPage = 0;
Index: prnt/hpijs/services.h
===================================================================
RCS file: /cvsroot/pkg-hpijs/hplip/prnt/hpijs/services.h,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 services.h
--- prnt/hpijs/services.h       14 Sep 2005 17:36:23 -0000      1.1.1.5
+++ prnt/hpijs/services.h       11 May 2006 03:13:47 -0000
@@ -35,6 +35,8 @@
 #include <stdio.h>
 #include <math.h>
 
+#include "global_types.h"
+
 APDK_USING_NAMESPACE
 
 class UXServices:public SystemServices
@@ -123,10 +125,10 @@
   const float *Margin;
   int Model;      /* selected device: -1=no, 1=yes */
   int OutputPath;   /* open file descriptor */
-  int Quality;       /* 0=normal, 1=draft, 2=best */
-  int MediaType;     /* 0=plain, 1=premium, 2=photo */
-  int ColorMode;     /* 0=grey_k, 1=grey_cmy, 2=color */
-  int PenSet;        /* 0=black_pen, 1=color_pen, 2=both_pens, 3=mdl_pen, 
4=mdl_both */
+  QUALITY_MODE Quality;
+  MEDIATYPE MediaType;
+  COLORMODE ColorMode;
+  PEN_TYPE PenSet;
   int MediaPosition;
   float PaperWidth;    /* physical width in inches */
   float PaperHeight;   /* physical height in inches */

Reply via email to