bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bugs #9923] get_short returns incorrect values for -ve inputs on Solari


From: James Youngman
Subject: [bugs #9923] get_short returns incorrect values for -ve inputs on Solaris 8
Date: Sun, 08 Aug 2004 07:42:10 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Epiphany/1.0.8

This mail is an automated notification from the bugs tracker
 of the project: findutils.




/**************************************************************************/
[bugs #9923] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=9923>
Project: findutils
Submitted by: James Youngman
On: Sun 08/08/2004 at 11:31

Category:  locate
Severity:  1 - None
Item Group:  None
Resolution:  None
Assigned to:  jay
Originator Name:  
Originator Email:  n Lazenbatt <address@hidden>
Status:  Open
Release:  None
Fixed Release:  None


Summary:  get_short returns incorrect values for -ve inputs on Solaris 8

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
00 00 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




CC List
-------

CC Address                          | Comment
------------------------------------+-----------------------------
john --AT-- ssl --DOT-- co --DOT-- uk | 









For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=9923>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/







reply via email to

[Prev in Thread] Current Thread [Next in Thread]