bugfindutils - Bugs: bug #13303, find should filter out...


bug #13303: find should filter out non-printable characters if outputting to tty

Submitter:  Andreas Metzler <ametzler>
Submitted:  Sun 05 Jun 2005 12:02:58 PM UTC
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Fixed
Privacy:  Public Assigned to:  jay
Originator Name:  Vincent Lefevre Open/Closed:  Closed
Release:  4.2.20 Fixed Release:  4.2.21
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Sat 11 Jan 2014 02:18:14 PM UTC, comment #7: 

Bob Proulx suggests that this change may have introduced a POSIX non-compliance.

James Youngman <jay>
Project Administrator
Tue 07 Jun 2005 11:38:11 PM UTC, comment #6: 

You can download a release of findutils in which this problem is
fixed from ftp://alpha.gnu.org/gnu/findutils.

The releases on alpha.gnu.org are for testing purposes, so please
take the time to download the release and verify that your
problem has been solved.  Once the release has been sufficiently
tested, it can be uploaded to ftp.gnu.org for everybody to use it.

James Youngman <jay>
Project Administrator
Tue 07 Jun 2005 07:40:08 PM UTC, comment #5: 

This problem is fixed in the CVS code for findutils.
To resolve your problem, you could either wait for the
next official release of findutils, or check out a copy
of the code from the CVS repository for findutils.

James Youngman <jay>
Project Administrator
Tue 07 Jun 2005 08:10:49 AM UTC, comment #4: 

Here is an updated patch which remedies the problem found by 860 Dmitry V. Levin (double output for -fprint).  diff -p used :)

James Youngman <jay>
Project Administrator
Mon 06 Jun 2005 08:07:59 PM UTC, comment #3: 

I like the idea, but the patch is quite large.
One mistake found so far: the change to pred_fprint() will result to double print.

P.S. Could you please add -p option to "cvs diff" command next time?

Dmitry V. Levin <ldv>
Sun 05 Jun 2005 11:35:46 PM UTC, comment #2: 

I propose the attached patch (against current CVS).   Please try it out and let me know if you're happy with the result. 

The patch affects -print, -fprint, -fprintf, -printf.   It does not affect -ok, -okdir or -print0.    The -ls and -fls actions already had escaping. 

The escape style for -print and friends is different to that used by -ls.   This is explained in the documentation, which is also patched.   Please let me know how intelligible you find the (updated) documentation.

One could argue that -ok and -okdir should be fixed.  It's not immediately obvious what the best way of doing that is.


James Youngman <jay>
Project Administrator
Sun 05 Jun 2005 02:36:37 PM UTC, comment #1: 

My first instinct is to follow the behaviour of "ls", which seems sensible.  However, I've started a discussion on the bug-findutils mailing list.

James Youngman <jay>
Project Administrator
Sun 05 Jun 2005 12:02:58 PM UTC, original submission:  

This is http://bugs.debian.org/311384 reported against the Debian bug tracking system.

Vincent Lefevre <vincent@vinc17.org> writes:
The "find" command should filter out non-printable characters when the output stream (stdout or stderr) is attached to a terminal. Otherwise escape sequences may be sent to the terminal, for instance when there are filenames encoded in UTF-8 and the user has ISO-8859 locales. Also

$ touch "test`tput mc0`"
$ find .

will print some data if your terminal supports printing (e.g. xterm, if this support hasn't been disabled by setting printerCommand to an empty string). This is bad for the security/privacy as some malicious user may create such a filename...

Afaict dumping non printable characters to the terminal usually is not wanted and should not be default.

Posix says:
    The primary shall always evaluate as true; it shall cause
    the current pathname to be written to standard output.

so by filtering out these characters (e.g by replacing them with questionmarks or their escapecodes) we would not be following posix to the letter. But do you want to be that strict?
            cu andreas

Andreas Metzler <ametzler>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #3063:  escaped-terminal-output-2.patch added by jay (30KiB - text/x-patch - Second proposed patch (replacing the first) against current CVS)
file #3042:  escaped-terminal-output.patch added by jay (28KiB - text/x-patch - Proposed patch (1) against current CVS)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by jay (Posted a comment)
  • -email is unavailable- added by ametzler (submitter and BTS)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2005-06-07 jay Open/ClosedOpen Closed
        Fixed ReleaseNone 4.2.21
    2005-06-07 jay Dependencies- bugs #13325 is dependent
    2005-06-07 jay StatusReady For Test Fixed
    2005-06-07 jay Attached File- Added escaped-terminal-output-2.patch, #2579
    2005-06-06 ldv Carbon-Copy- Added ldv
    2005-06-05 jay Item GroupNone Wrong result
        StatusNone Ready For Test
        Assigned toNone jay
    2005-06-05 jay Attached File- Added escaped-terminal-output.patch, #2576
    2005-06-05 ametzler Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.9