Red Hat Bugzilla – Bug 160078
hostid returns sign extended 64 bit value on 64 bit platforms
Last modified: 2010-10-06 09:46:14 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):
Steps to Reproduce:
1.set your system hostid to 0x80000000
on 64 bit platforms, 0xffffffff80000000 is printed
on 32 bit platforms 0x80000000 is printed
all platforms should print 0x80000000
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.
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.
Fixed in CVS for Fedora development.
A better fix is to use "%x", since otherwise small values will be space-padded.
it's reproduced on RHEL-3 x86_64, should a new bugzilla be filled?
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.
How to update coreutils without internet connection