about summary refs log tree commit diff
path: root/converter/other
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-11-26 01:55:41 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-11-26 01:55:41 +0000
commita98484391d99d3ba18c9efec66c2587ddd9393a0 (patch)
treec3d7ce3fe167df2838d9ca290f4924fff7db4b90 /converter/other
parent9d3e993cb53679bbd3f636a61d765b0be43d30b9 (diff)
downloadnetpbm-mirror-a98484391d99d3ba18c9efec66c2587ddd9393a0.tar.gz
netpbm-mirror-a98484391d99d3ba18c9efec66c2587ddd9393a0.tar.xz
netpbm-mirror-a98484391d99d3ba18c9efec66c2587ddd9393a0.zip
Release 10.35.34
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@472 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r--converter/other/pamtopfm.c2
-rw-r--r--converter/other/xwdtopnm.c20
2 files changed, 19 insertions, 3 deletions
diff --git a/converter/other/pamtopfm.c b/converter/other/pamtopfm.c
index 44a8ab08..ee44eeb5 100644
--- a/converter/other/pamtopfm.c
+++ b/converter/other/pamtopfm.c
@@ -279,7 +279,7 @@ main(int argc, char **argv ) {
 
     ifP = pm_openr(cmdline.inputFilespec);
 
-    tuplenArray = pnm_readpamn(ifP, &pam, sizeof(pam));
+    tuplenArray = pnm_readpamn(ifP, &pam, PAM_STRUCT_SIZE(tuple_type));
 
     writePfmHeader(stdout, 
                    makePfmHeader(&pam, cmdline.scale, cmdline.endian));
diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
index 28c38cfc..4ff7d2ec 100644
--- a/converter/other/xwdtopnm.c
+++ b/converter/other/xwdtopnm.c
@@ -222,7 +222,15 @@ processX10Header(X10WDFileHeader *  const h10P,
         /* Must be grayscale. */
         *formatP = PGM_TYPE;
         *visualclassP = StaticGray;
-        *maxvalP = ( 1 << h10P->display_planes ) - 1;
+        if (h10P->display_planes > sizeof(*maxvalP) * 8 - 1)
+            pm_error("XWD header says display_planes = %u, which is "
+                     "too large for this program to compute",
+                     h10P->display_planes);
+        *maxvalP = ((xelval)1 << h10P->display_planes) - 1;
+        if (*maxvalP > PNM_OVERALLMAXVAL)
+            pm_error("XWD header says display_planes = %u, which is too "
+                     "large for maximum maxval of %u",
+                     h10P->display_planes, PNM_OVERALLMAXVAL);
         *colorsP = pnm_allocrow( *maxvalP + 1 );
         for ( i = 0; i <= *maxvalP; ++i )
             PNM_ASSIGN1( (*colorsP)[i], i );
@@ -520,7 +528,15 @@ processX11Header(X11WDFileHeader *  const h11P,
     } else if ( *visualclassP == StaticGray ) {
         unsigned int i;
         *formatP = PGM_TYPE;
-        *maxvalP = ( 1 << h11FixedP->bits_per_pixel ) - 1;
+        if (h11FixedP->bits_per_pixel > sizeof(*maxvalP) * 8 - 1)
+            pm_error("XWD header says bits_per_pixel = %u, which is "
+                     "too large for this program to compute",
+                     h11FixedP->bits_per_pixel);
+        *maxvalP = ((xelval)1 << h11FixedP->bits_per_pixel) - 1;
+        if (*maxvalP > PNM_OVERALLMAXVAL)
+            pm_error("XWD header says bits_per_pixel = %u, which is too "
+                     "large for maximum maxval of %u",
+                     h11FixedP->bits_per_pixel, PNM_OVERALLMAXVAL);
         *colorsP = pnm_allocrow( *maxvalP + 1 );
         for ( i = 0; i <= *maxvalP; ++i )
             PNM_ASSIGN1( (*colorsP)[i], i );