GNU bug report logs - #50070
chmod reads uninitialized variables when fts_info is an error and -v is set, leading to random error messages

Previous Next

Package: coreutils;

Reported by: Michael Debertol <michael.debertol <at> gmail.com>

Date: Sun, 15 Aug 2021 20:17:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

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 50070 in the body.
You can then email your comments to 50070 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 bug-coreutils <at> gnu.org:
bug#50070; Package coreutils. (Sun, 15 Aug 2021 20:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Debertol <michael.debertol <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 15 Aug 2021 20:17:02 GMT) Full text and rfc822 format available.

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

From: Michael Debertol <michael.debertol <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: chmod reads uninitialized variables when fts_info is an error and -v
 is set, leading to random error messages
Date: Sun, 15 Aug 2021 22:15:58 +0200
Hi,

I noticed that when running chmod with -v on a dangling symlink the 
error message is somewhat random:

> ln -s file-that-does-not-exist lnk

> chmod -w lnk -v

> chmod: cannot operate on dangling symlink 'lnk'

> failed to change mode of 'lnk' from 0000 (---------) to 7777 (rwsrwsrwt)

> chmod -w lnk -v

> chmod: cannot operate on dangling symlink 'lnk'

> failed to change mode of 'lnk' from 0000 (---------) to 7775 (rwsrwsr-t)

> chmod -w lnk -v

> chmod: cannot operate on dangling symlink 'lnk'

> failed to change mode of 'lnk' from 0000 (---------) to 7774 (rwsrwsr-T)


(note that the value for "to" is different)

This appears to be because in the process_file function, old_mode and 
new_mode are only set when ok is true. When chmod encounters a dangling 
symlink, ok will be false and old_mode/new_mode won't be set. However, 
old_mode and new_mode are still accessed for the invocation of 
describe_change if verbosity is set to high, leading to incorrect error 
messages.

I think a better behavior could be to not print the "from mode to mode" 
part of the error message if the file could not be accessed, since it is 
meaningless anyways.

Have a nice day,

Michael





Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Mon, 16 Aug 2021 04:34:01 GMT) Full text and rfc822 format available.

Notification sent to Michael Debertol <michael.debertol <at> gmail.com>:
bug acknowledged by developer. (Mon, 16 Aug 2021 04:34:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Michael Debertol <michael.debertol <at> gmail.com>
Cc: 50070-done <at> debbugs.gnu.org
Subject: Re: bug#50070: chmod reads uninitialized variables when fts_info is
 an error and -v is set, leading to random error messages
Date: Sun, 15 Aug 2021 21:33:26 -0700
[Message part 1 (text/plain, inline)]
Thanks for reporting the bug. I installed the attached patch to fix it.
[0001-chmod-fix-use-of-uninitialized-var-if-v.patch (text/x-patch, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 13 Sep 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 274 days ago.

Previous Next


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