Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 160078 - hostid returns sign extended 64 bit value on 64 bit platforms
Summary: hostid returns sign extended 64 bit value on 64 bit platforms
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils
Version: 4.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Tim Waugh
QA Contact:
Depends On:
Blocks: 181411
TreeView+ depends on / blocked
Reported: 2005-06-10 17:25 UTC by Neil Horman
Modified: 2010-10-06 13:46 UTC (History)
2 users (show)

Fixed In Version: RHBA-2006-0313
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-08-10 21:11:06 UTC
Target Upstream Version:

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

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2006:0313 normal SHIPPED_LIVE coreutils bug fix update 2006-08-09 04:00:00 UTC

Description Neil Horman 2005-06-10 17:25:57 UTC
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 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 17:29:48 UTC
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 10:59:18 UTC
Sent upstream.

Fixed in CVS for Fedora development.

Comment 10 Tim Waugh 2005-06-16 12:30:10 UTC
A better fix is to use "%x", since otherwise small values will be space-padded.

Comment 12 Tru Huynh 2005-09-07 16:45:43 UTC

it's reproduced on RHEL-3 x86_64, should a new bugzilla be filled?

Comment 13 Tim Waugh 2005-09-07 17:11:24 UTC
Yes please.

Comment 37 Red Hat Bugzilla 2006-08-10 21:11:06 UTC
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 13:46:14 UTC
How to update coreutils without internet connection

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