Bug 58745 - rawtopgm mishandles littleendian flag
Summary: rawtopgm mishandles littleendian flag
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: netpbm
Version: 7.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-01-23 23:21 UTC by Joe Krahn
Modified: 2015-03-05 01:10 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2002-03-04 22:48:17 UTC
Embargoed:


Attachments (Terms of Use)

Description Joe Krahn 2002-01-23 23:21:53 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.78C-MyBrowser [en] (X11; U; Linux 2.4.9-13 i686)

Description of problem:
Using rawtopgm with 2-byte images gives the same result with or without the
-littleendian flag.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. rawtopgm -bpp 2 -littleendian 100 100 raw.data >little.pgm
2. rawtopgm -bpp 2 100 100 raw.data >big.pgm
3. diff little.pgm big.pgm
	

Additional info:

looking in the current netpbm source, rawtopgm calls read_from_file
function incorrectly, using:
read_from_file(ifp,bpp,littleendian,row,col)

but should be:
read_from_file(ifp,bpp,row,col,littleendian)

SO, littleendian  flag is actually the row number, and we
have a big-endian first row followed by all little-endian
rows.

Bad row & col values don't hurt anything because it's
only for error messages.

Comment 1 Joe Krahn 2002-01-24 02:44:01 UTC
It looks like rowskip is also mangled in rawtopgm. In i386 RedHat 7.2,
rowskip values seem to have no effect. Compiling netpbm for IRIX, I
found that declaring rowskip as double doesn't work when processing
arguments as type OPT_FLOAT. Rowskip should be a float.

Also, it seems that rowskip is a flot to support non-integral skip
amounts. This must be useful sometimes, but non-integer values
won't work for 16 bit raw data. The endianness will flip because there's
no attempt to skip in integral 16 bit amounts.

Comment 2 Phil Knirsch 2002-02-27 10:50:32 UTC
I'll updated the netpbm package to the latest release in the next couple of
days. If you could give that on a shot and see if that fixes your problem i'd
greately appreciate it.

Read ya, Phil

Comment 3 Joe Krahn 2002-03-04 22:48:13 UTC
It looks like the littleendian flag got fixed, but now
there's another bug. It only shows up with -O3 optimization.
In this piece of code:

compute_image_size(const struct cmdline_info cmdline, const long nread,
                   int * const rows_p, int * const cols_p) {
    if (cmdline.autosize) {


cmdline.autosize is treated as always true, but only with -O3.
Strangely, if I print that value anywhere within the subroutine,
it works OK. It also works OK if I remove the const qualifier
from the cmdline argument. Dang...

Otherwise looks good.


Comment 4 Phil Knirsch 2002-03-18 15:15:17 UTC
OK, i've updated the netpbm to the latest release (9.24), so i'm closing this
bug as resolved rawhide.

As we don't build our packages with -O3 but rather -O2 the second bug you
mentioned shouldn't happen, so everything should work as expected. :-)

Read ya, Phil


Note You need to log in before you can comment on or make changes to this bug.