bugfindutils - Bugs: bug #9923, get_short returns incorrect values...

 
 

bug #9923: get_short returns incorrect values for -ve inputs on Solaris 8

Submitted by:  James Youngman <jay>
Submitted on:  Sun 08 Aug 2004 11:31:56 AM UTC  
 
Category: locateSeverity: 1 - Wish
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: James Youngman <jay>
Originator Name: Open/Closed: Closed
Release: NoneFixed Release: 4.2.0

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sun 08 Aug 2004 11:46:47 AM UTC, comment #2:

Could you please test the fixed code (in CVS) and let me know the outcome? Thanks.

James Youngman <jay>
Project AdministratorIn charge of this item.
Sun 08 Aug 2004 11:46:15 AM UTC, comment #1:

This problem is fixed in the CVS code for findutils.
To resolve your problem, you could either wait for the
next official release of findutils, or check out a copy
of the code from the CVS repository for findutils.

James Youngman <jay>
Project AdministratorIn charge of this item.
Sun 08 Aug 2004 11:31:56 AM UTC, original submission:

Hi there

I'm contacting you as maintainer of the GNU findutils package.

I found a bug in findutils locate on Solaris 8. It was reading back negative 16-bit shorts as positive 32-bit ints. Here's the original code from findutils-4.1/locate/locate.c, starting at line 79:

/* Read in a 16-bit int, high byte first (network byte order). */

static int
get_short (fp)
FILE *fp;
{
register short x;

x = fgetc (fp);
return (x << 8) | (fgetc (fp) & 0xff);
}

get_short is called like this (count is an int):

count += get_short (fp);

I compiled on Solaris 8 with gcc version 2.95.3 20010315. I found -141 was saved in locatedb as \377 \163 but the number added to count was
\000 \000 \377 \163 or 65395.

The solution was just to make get_short return a short instead of an int:

static short
get_short(fp)
...

John
--
John Lazenbatt
System Simulation Ltd

James Youngman <jay>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sat 16 Oct 2004 06:23:15 PM UTCjayOpen/ClosedOpen=>Closed
  Fixed ReleaseNone=>4.2.0
Sun 08 Aug 2004 11:46:15 AM UTCjayStatusNone=>Fixed
Sun 08 Aug 2004 11:31:56 AM UTCjayCarbon-Copy-=>Added john --AT-- ssl --DOT-- co --DOT-- uk

Back to the top


Powered by Savane 3.1-cleanup1