]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
libcom_err: Fix sign-extension problem on 64-bit systems in error_message()
authorTheodore Ts'o <tytso@mit.edu>
Sun, 16 Dec 2007 03:31:03 +0000 (22:31 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 16 Dec 2007 03:31:03 +0000 (22:31 -0500)
commit6b6c27fb8a45f264194d8dd637643d8b4898271a
tree0cfb86071e43ba79a2d53b970256acfa6d7172a3
parent20c10a766788d9271e36f3ba3b0682a3027cb272
libcom_err: Fix sign-extension problem on 64-bit systems in error_message()

On 64-bit systems (or anything with sizeof(long) > sizeof(int)), we
sometimes get error codes passed to error_message which have been cast
from an (int) to an (unsigned int). This almost always happens if
you're using libgssapi_krb5, which returns an error code which is less
than 0 but is returned in an (unsigned int).

For example, -1765328377L gets cast to 2529638919, which is
0x96c73a07, not 0xffffffff96c73a07, so error_message() fails to find a
matching error table.

When error_message() then calls the error_table_name() function to get a
name to use in the "unknown code" message, it gets a correct value back.

This happens because error_table_name() drops most of the higher bits of
the parameter it's passed before doing anything else with it (& 077777777f,
or & 0xffffff). If we did the same thing in error_message(), we wouldn't
have a problem there, either.

Problem reported and fixed by: Nalin Dahyabhai

Addresses-Sourceforge-Bug: #1809658

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/et/error_message.c