Bug 160078 - hostid returns sign extended 64 bit value on 64 bit platforms
hostid returns sign extended 64 bit value on 64 bit platforms
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Depends On:
Blocks: 181411
  Show dependency treegraph
Reported: 2005-06-10 13:25 EDT by Neil Horman
Modified: 2010-10-06 09:46 EDT (History)
2 users (show)

See Also:
Fixed In Version: RHBA-2006-0313
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-08-10 17:11:06 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch to correct formatting on returned value from gethostid (270 bytes, patch)
2005-06-10 13:29 EDT, Neil Horman
no flags Details | Diff

  None (edit)
Description Neil Horman 2005-06-10 13:25:57 EDT
Description of problem:
when running hostid on a 64 bit arch, if the most significant bit of the hostid
value is 1, then the returned value will be a sign extended 64 bit value, rather
than the 32 bit value as defined in POSIX.

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

How reproducible:

Steps to Reproduce:
1.set your system hostid to 0x80000000
2.run hostid

Actual results:
on 64 bit platforms, 0xffffffff80000000 is printed
on 32 bit platforms 0x80000000 is printed

Expected results:
all platforms should print 0x80000000

Additional info:
This changed in the U5 update of glibc, where the maintainer corrected the
behavior of gethostid.  gethostid is broken anyway, as it returns a long, and
that is a different size on 32 vs. 64 bit arches.  it was corrected to sign
extend the return value, which for hostid, which simply prints out the value
with a %lx formatting, translates into a 64 bit representation, rather than a 32
bit representation when the leading bits were all zero.
Comment 1 Neil Horman 2005-06-10 13:29:48 EDT
Created attachment 115298 [details]
patch to correct formatting on returned value from gethostid

This patch fixes up the returned value from gethostid, so that any sign
extension will be truncated, and the hostid will be displayed as the 32 bit
integer it is defined to be in the spec.
Comment 3 Tim Waugh 2005-06-16 06:59:18 EDT
Sent upstream.

Fixed in CVS for Fedora development.
Comment 10 Tim Waugh 2005-06-16 08:30:10 EDT
A better fix is to use "%x", since otherwise small values will be space-padded.
Comment 12 Tru Huynh 2005-09-07 12:45:43 EDT

it's reproduced on RHEL-3 x86_64, should a new bugzilla be filled?
Comment 13 Tim Waugh 2005-09-07 13:11:24 EDT
Yes please.
Comment 37 Red Hat Bugzilla 2006-08-10 17:11:06 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

Comment 40 ranjithml 2010-10-06 09:46:14 EDT
How to update coreutils without internet connection

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