GNU bug report logs - #7201
unportable integer expression in src/install.c

Previous Next

Package: coreutils;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Tue, 12 Oct 2010 19:37:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7201 in the body.
You can then email your comments to 7201 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7201; Package coreutils. (Tue, 12 Oct 2010 19:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> cs.ucla.edu>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 12 Oct 2010 19:37:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Bug-coreutils <bug-coreutils <at> gnu.org>
Subject: unportable integer expression in src/install.c
Date: Tue, 12 Oct 2010 12:39:27 -0700
Solaris 10 cc issues this warning:

"install.c", line 189: warning: initializer does not fit or is out of range: -61952

and indeed the code in question relies on undefined
behavior, as it shoehorns what may be a large negative
number into a small int variable.  Here's a patch
to src/install.c.  Maybe you should remove the "const"
while you're at it, as it's not that helpful here?

--- src/install.c~  2010-09-27 23:00:50.000000000 -0700
+++ src/install.c   2010-10-12 12:35:30.277787068 -0700
@@ -186,8 +186,8 @@ have_same_content (int a_fd, int b_fd)
 static bool
 extra_mode (mode_t input)
 {
-  const mode_t mask = ~S_IRWXUGO & ~S_IFMT;
-  return !! (input & mask);
+  const mode_t mask = S_IRWXUGO | S_IFMT;
+  return !! (input & ~ mask);
 }

 /* Return true if copy of file SRC_NAME to file DEST_NAME is necessary. */




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7201; Package coreutils. (Tue, 12 Oct 2010 19:55:02 GMT) Full text and rfc822 format available.

Message #8 received at 7201 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 7201 <at> debbugs.gnu.org
Subject: Re: bug#7201: unportable integer expression in src/install.c
Date: Tue, 12 Oct 2010 21:57:33 +0200
Paul Eggert wrote:
> Solaris 10 cc issues this warning:
>
> "install.c", line 189: warning: initializer does not fit or is out of range: -61952
>
> and indeed the code in question relies on undefined
> behavior, as it shoehorns what may be a large negative
> number into a small int variable.  Here's a patch
> to src/install.c.  Maybe you should remove the "const"
> while you're at it, as it's not that helpful here?
>
> --- src/install.c~  2010-09-27 23:00:50.000000000 -0700
> +++ src/install.c   2010-10-12 12:35:30.277787068 -0700
> @@ -186,8 +186,8 @@ have_same_content (int a_fd, int b_fd)
>  static bool
>  extra_mode (mode_t input)
>  {
> -  const mode_t mask = ~S_IRWXUGO & ~S_IFMT;
> -  return !! (input & mask);
> +  const mode_t mask = S_IRWXUGO | S_IFMT;
> +  return !! (input & ~ mask);

Thanks!  That looks sufficiently safe.
You're welcome to commit/push that.
Or I will do it for you tomorrow.




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 17 Apr 2011 08:59:01 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> cs.ucla.edu>:
bug acknowledged by developer. (Sun, 17 Apr 2011 08:59:01 GMT) Full text and rfc822 format available.

Message #13 received at 7201-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: 7201-done <at> debbugs.gnu.org
Subject: Re: bug#7201: unportable integer expression in src/install.c
Date: Sun, 17 Apr 2011 10:58:14 +0200
Jim Meyering wrote:

> Paul Eggert wrote:
>> Solaris 10 cc issues this warning:
>>
>> "install.c", line 189: warning: initializer does not fit or is out
>> of range: -61952
>>
>> and indeed the code in question relies on undefined
>> behavior, as it shoehorns what may be a large negative
>> number into a small int variable.  Here's a patch
>> to src/install.c.  Maybe you should remove the "const"
>> while you're at it, as it's not that helpful here?
>>
>> --- src/install.c~  2010-09-27 23:00:50.000000000 -0700
>> +++ src/install.c   2010-10-12 12:35:30.277787068 -0700
>> @@ -186,8 +186,8 @@ have_same_content (int a_fd, int b_fd)
>>  static bool
>>  extra_mode (mode_t input)
>>  {
>> -  const mode_t mask = ~S_IRWXUGO & ~S_IFMT;
>> -  return !! (input & mask);
>> +  const mode_t mask = S_IRWXUGO | S_IFMT;
>> +  return !! (input & ~ mask);
>
> Thanks!  That looks sufficiently safe.
> You're welcome to commit/push that.
> Or I will do it for you tomorrow.

Applied long ago.  Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 15 May 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 97 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.