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

 
 

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

Submitter:  James Youngman <jay>
Submitted:  Sun 08 Aug 2004 11:31:56 AM UTC
   
 
Category:  locate Severity:  1 - Wish
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  jay
Originator Name:  Open/Closed:  Closed
Release:  None Fixed Release:  4.2.0
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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>
Group administrator
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>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-10-16 jay Open/ClosedOpen Closed
    Fixed ReleaseNone 4.2.0
2004-08-08 jay StatusNone Fixed
2004-08-08 jay Carbon-Copy- Added john --AT-- ssl --DOT-- co --DOT-- uk

Back to the top

Powered by Savane 3.13-f8d8.
Corresponding source code