[Bug bzip2/25492] bzip2.c: ignoring return value of ‘fchown’
mark at klomp dot org
sourceware-bugzilla@sourceware.org
Sun May 17 13:00:42 GMT 2020
https://sourceware.org/bugzilla/show_bug.cgi?id=25492
Mark Wielaard <mark at klomp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |mark at klomp dot org
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
I don't think this is a real bug. First we do "check" the result, by throwing
it away, that is what the (void) does. And my compiler doesn't show that
warning, even with -Wunused-result.
This is the whole function:
static
void applySavedFileAttrToOutputFile ( IntNative fd )
{
# if BZ_UNIX
IntNative retVal;
retVal = fchmod ( fd, fileMetaInfo.st_mode );
ERROR_IF_NOT_ZERO ( retVal );
(void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
/* chown() will in many cases return with EPERM, which can
be safely ignored.
*/
# endif
}
As you can see, the comment already explains why we don't care.
What the function tried to do is set the attributes of the new output file to
the same attributes of the input file. So if your input file was owned by user
mark, it will try to set the output file to the same owner. If you aren't the
user mark, but only had read permission to the input file, and you don't have
permission to change the owner of a file, then the output file will just be
owned by you.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Bzip2-devel
mailing list