Package: netpbm
Version: 2:10.0-10.1jim
Severity: normal
Tags: patch
xwdtopnm is broken on 64-bit systems because it assumes "long" is 32
bits. The attached patch replaces
long -> int32n
unsigned long -> uint32n
This patch has been tested to work on both 32 and 64 bit systems.
-jim
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14-2-amd64-k8
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages netpbm depends on:
ii libc6 2.3.5-8.1 GNU C Library: Shared libraries an
ii libjpeg62 6b-10 The Independent JPEG Group's JPEG
ii libnetpbm10 2:10.0-10.1jim Shared libraries for netpbm
ii libpng12-0 1.2.8rel-5 PNG library - runtime
ii libtiff4 3.7.4-1 Tag Image File Format (TIFF) libra
ii zlib1g 1:1.2.3-8 compression library - runtime
Versions of packages netpbm recommends:
ii gs 8.15-4 Transitional package
ii gs-esp [gs] 8.15.1.dfsg.1-1 The Ghostscript PostScript interpr
ii gs-gpl [gs] 8.15-4 The GPL Ghostscript PostScript int
-- no debconf information
diff -ur netpbm-free-10.0.orig/pnm/x11wd.h netpbm-free-10.0/pnm/x11wd.h
--- netpbm-free-10.0.orig/pnm/x11wd.h 2003-08-14 15:38:51.000000000 -0400
+++ netpbm-free-10.0/pnm/x11wd.h 2006-02-10 13:55:13.000000000 -0500
@@ -58,7 +58,7 @@
} X11WDFileHeader;
typedef struct {
- unsigned long num;
+ uint32n num;
unsigned short red, green, blue;
char flags; /* do_red, do_green, do_blue */
char pad;
Only in netpbm-free-10.0/pnm: xwdtopnm
diff -ur netpbm-free-10.0.orig/pnm/xwdtopnm.c netpbm-free-10.0/pnm/xwdtopnm.c
--- netpbm-free-10.0.orig/pnm/xwdtopnm.c 2003-08-14 15:38:51.000000000 -0400
+++ netpbm-free-10.0/pnm/xwdtopnm.c 2006-02-10 14:05:35.000000000 -0500
@@ -52,7 +52,7 @@
Which of the members applies depends on the bits per item of
the input image.
*/
- long l; /* 32 bits per item */
+ int32n l; /* 32 bits per item */
short s; /* 16 bits per item */
char c; /* 8 bits per item */
} item;
@@ -65,7 +65,7 @@
/* This is the number of bits in the current item that have not yet
been returned as part of a pixel or saved as carryover bits.
*/
- unsigned long carryover_bits;
+ uint32n carryover_bits;
/* This is the odd bits left over from one item that need to be
combined with more bits from the next item to form a pixel
value (the pixel is split between two items). An item is a
@@ -79,20 +79,20 @@
};
static short bs_short ARGS(( short s ));
-static long bs_long ARGS(( long l ));
+static int32n bs_int32 ARGS(( int32n l ));
static int byte_swap;
static int
-zero_bits(const unsigned long mask) {
+zero_bits(const uint32n mask) {
/*----------------------------------------------------------------------------
Return the number of consective zero bits at the least significant end
of the binary representation of 'mask'. E.g. if mask == 0x00fff800,
we would return 11.
-----------------------------------------------------------------------------*/
int i;
- unsigned long shifted_mask;
+ uint32n shifted_mask;
for (i=0, shifted_mask = mask;
i < sizeof(mask)*8 && (shifted_mask & 0x00000001) == 0;
@@ -103,12 +103,12 @@
static int
-one_bits(const unsigned long input) {
+one_bits(const uint32n input) {
/*----------------------------------------------------------------------------
Return the number of one bits in the binary representation of 'input'.
-----------------------------------------------------------------------------*/
int one_bits;
- unsigned long mask;
+ uint32n mask;
one_bits = 0; /* initial value */
for (mask = 0x00000001; mask != 0x00000000; mask <<= 1)
@@ -124,8 +124,8 @@
int * const padrightP, xelval * const maxvalP,
enum visualclass * const visualclassP, int * const formatP,
xel ** const colorsP, int * const bits_per_pixelP,
- int * const bits_per_itemP, unsigned long * const red_maskP,
- unsigned long * const green_maskP, unsigned long * const blue_maskP,
+ int * const bits_per_itemP, uint32n * const red_maskP,
+ uint32n * const green_maskP, uint32n * const blue_maskP,
enum byteorder * const byte_orderP,
enum byteorder * const bit_orderP)
{
@@ -148,7 +148,7 @@
pm_error( "couldn't read XWD file header" );
if ( h10P->file_version == X10WD_FILE_VERSION ||
- bs_long( h10P->file_version ) == X10WD_FILE_VERSION )
+ bs_int32( h10P->file_version ) == X10WD_FILE_VERSION )
{
int i;
X10Color* x10colors;
@@ -156,13 +156,13 @@
if ( h10P->file_version != X10WD_FILE_VERSION )
{
byte_swap = 1;
- h10P->header_size = bs_long( h10P->header_size );
- h10P->file_version = bs_long( h10P->file_version );
- h10P->display_type = bs_long( h10P->display_type );
- h10P->display_planes = bs_long( h10P->display_planes );
- h10P->pixmap_format = bs_long( h10P->pixmap_format );
- h10P->pixmap_width = bs_long( h10P->pixmap_width );
- h10P->pixmap_height = bs_long( h10P->pixmap_height );
+ h10P->header_size = bs_int32( h10P->header_size );
+ h10P->file_version = bs_int32( h10P->file_version );
+ h10P->display_type = bs_int32( h10P->display_type );
+ h10P->display_planes = bs_int32( h10P->display_planes );
+ h10P->pixmap_format = bs_int32( h10P->pixmap_format );
+ h10P->pixmap_width = bs_int32( h10P->pixmap_width );
+ h10P->pixmap_height = bs_int32( h10P->pixmap_height );
h10P->window_width = bs_short( h10P->window_width );
h10P->window_height = bs_short( h10P->window_height );
h10P->window_x = bs_short( h10P->window_x );
@@ -268,7 +268,7 @@
*bit_orderP = LSBFirst;
}
else if ( h11P->file_version == X11WD_FILE_VERSION ||
- bs_long( h11P->file_version ) == X11WD_FILE_VERSION )
+ bs_int32( h11P->file_version ) == X11WD_FILE_VERSION )
{
int i;
X11XColor* x11colors;
@@ -278,31 +278,31 @@
if ( h11P->file_version != X11WD_FILE_VERSION )
{
byte_swap = 1;
- h11P->header_size = bs_long( h11P->header_size );
- h11P->file_version = bs_long( h11P->file_version );
- h11P->pixmap_format = bs_long( h11P->pixmap_format );
- h11P->pixmap_depth = bs_long( h11P->pixmap_depth );
- h11P->pixmap_width = bs_long( h11P->pixmap_width );
- h11P->pixmap_height = bs_long( h11P->pixmap_height );
- h11P->xoffset = bs_long( h11P->xoffset );
- h11P->byte_order = bs_long( h11P->byte_order );
- h11P->bitmap_unit = bs_long( h11P->bitmap_unit );
- h11P->bitmap_bit_order = bs_long( h11P->bitmap_bit_order );
- h11P->bitmap_pad = bs_long( h11P->bitmap_pad );
- h11P->bits_per_pixel = bs_long( h11P->bits_per_pixel );
- h11P->bytes_per_line = bs_long( h11P->bytes_per_line );
- h11P->visual_class = bs_long( h11P->visual_class );
- h11P->red_mask = bs_long( h11P->red_mask );
- h11P->green_mask = bs_long( h11P->green_mask );
- h11P->blue_mask = bs_long( h11P->blue_mask );
- h11P->bits_per_rgb = bs_long( h11P->bits_per_rgb );
- h11P->colormap_entries = bs_long( h11P->colormap_entries );
- h11P->ncolors = bs_long( h11P->ncolors );
- h11P->window_width = bs_long( h11P->window_width );
- h11P->window_height = bs_long( h11P->window_height );
- h11P->window_x = bs_long( h11P->window_x );
- h11P->window_y = bs_long( h11P->window_y );
- h11P->window_bdrwidth = bs_long( h11P->window_bdrwidth );
+ h11P->header_size = bs_int32( h11P->header_size );
+ h11P->file_version = bs_int32( h11P->file_version );
+ h11P->pixmap_format = bs_int32( h11P->pixmap_format );
+ h11P->pixmap_depth = bs_int32( h11P->pixmap_depth );
+ h11P->pixmap_width = bs_int32( h11P->pixmap_width );
+ h11P->pixmap_height = bs_int32( h11P->pixmap_height );
+ h11P->xoffset = bs_int32( h11P->xoffset );
+ h11P->byte_order = bs_int32( h11P->byte_order );
+ h11P->bitmap_unit = bs_int32( h11P->bitmap_unit );
+ h11P->bitmap_bit_order = bs_int32( h11P->bitmap_bit_order );
+ h11P->bitmap_pad = bs_int32( h11P->bitmap_pad );
+ h11P->bits_per_pixel = bs_int32( h11P->bits_per_pixel );
+ h11P->bytes_per_line = bs_int32( h11P->bytes_per_line );
+ h11P->visual_class = bs_int32( h11P->visual_class );
+ h11P->red_mask = bs_int32( h11P->red_mask );
+ h11P->green_mask = bs_int32( h11P->green_mask );
+ h11P->blue_mask = bs_int32( h11P->blue_mask );
+ h11P->bits_per_rgb = bs_int32( h11P->bits_per_rgb );
+ h11P->colormap_entries = bs_int32( h11P->colormap_entries );
+ h11P->ncolors = bs_int32( h11P->ncolors );
+ h11P->window_width = bs_int32( h11P->window_width );
+ h11P->window_height = bs_int32( h11P->window_height );
+ h11P->window_x = bs_int32( h11P->window_x );
+ h11P->window_y = bs_int32( h11P->window_y );
+ h11P->window_bdrwidth = bs_int32( h11P->window_bdrwidth );
}
for ( i = 0; i < h11P->header_size - sizeof(*h11P); ++i )
if ( getc( file ) == EOF )
@@ -441,7 +441,7 @@
-static unsigned long
+static uint32n
getpix(FILE *file, struct row_control * const row_controlP,
const int bits_per_pixel, const int bits_per_item,
const enum byteorder byte_order, const enum byteorder bit_order) {
@@ -479,7 +479,7 @@
*row_controlP.
-----------------------------------------------------------------------------*/
- unsigned long pixel;
+ uint32n pixel;
/* This is the pixel value we ultimately return. It is a 32 bit
bitstring, with the pixel value right-justified in it.
*/
@@ -488,6 +488,9 @@
/* This is the number of bits we need to take from the current
item to combine with carryover bits to form a pixel.
*/
+
+ long tmplong; /* For pm_read*long */
+
/*
if (pixel_count < 4)
pm_message("getting pixel %d", pixel_count);
@@ -517,18 +520,18 @@
break;
case 32:
- switch (byte_order) {
- case MSBFirst:
- if (pm_readbiglong(file, &row_controlP->item.l) == -1)
- pm_error( "error reading image" );
- break;
- case LSBFirst:
- if (pm_readlittlelong(file, &row_controlP->item.l) == -1)
- pm_error( "error reading image");
- break;
- }
- break;
-
+ switch (byte_order) {
+ case MSBFirst:
+ if (pm_readbiglong(file, &tmplong) == -1)
+ pm_error( "error reading image" );
+ break;
+ case LSBFirst:
+ if (pm_readlittlelong(file, &tmplong) == -1)
+ pm_error( "error reading image");
+ break;
+ }
+ row_controlP->item.l = tmplong;
+ break;
default:
pm_error( "can't happen" );
}
@@ -545,8 +548,8 @@
bits_to_take = bits_per_pixel - row_controlP->bits_carried_over;
{
- unsigned long bits_to_take_mask;
- static unsigned long bits_taken;
+ uint32n bits_to_take_mask;
+ static uint32n bits_taken;
/* The bits we took from the current item: 'bits_to_take' bits
right-justified in a 32 bit bitstring.
*/
@@ -604,7 +607,7 @@
/* Part, but not all, of the next pixel is in this item. Get it
into carryover_bits and then mark this item all used up.
*/
- unsigned long bits_left_mask;
+ uint32n bits_left_mask;
int bit_shift;
/* How far to shift item to get the bits that are left
right-justified
@@ -711,8 +714,8 @@
const enum byteorder byte_order, const enum byteorder bit_order,
const int padright, const int cols, const xelval maxval,
const int format,
- unsigned long red_mask, unsigned long green_mask,
- unsigned long blue_mask, const xel* const colors,
+ uint32n red_mask, uint32n green_mask,
+ uint32n blue_mask, const xel* const colors,
const enum visualclass visualclass
) {
@@ -741,7 +744,7 @@
unsigned int col;
for (col = 0; col < cols; ++col) {
- unsigned long pixel;
+ uint32n pixel;
/* This is a triplet of indices into the color map, packed
into this bit string according to red_mask, etc.
*/
@@ -779,7 +782,7 @@
blue_maxval = blue_mask >> blue_shift;
for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) {
- unsigned long pixel;
+ uint32n pixel;
pixel = getpix( ifp, &row_control,
bits_per_pixel, bits_per_item,
@@ -819,7 +822,7 @@
int rows, cols, format, padright, row;
int bits_per_pixel;
int bits_per_item;
- unsigned long red_mask, green_mask, blue_mask;
+ uint32n red_mask, green_mask, blue_mask;
xelval maxval;
enum visualclass visualclass;
enum byteorder byte_order, bit_order;
@@ -897,8 +900,8 @@
return u.s;
}
-static long
-bs_long( long l )
+static int32n
+bs_int32( int32n l )
{
union cheat u;
unsigned char t;