public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/66318] Error messages contain raw file name; malicious #line directives can do bad things
Date: Thu, 28 May 2015 03:20:00 -0000	[thread overview]
Message-ID: <bug-66318-4-s0Y9JOGwQT@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66318-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66318

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
You're right that the text of diagnostics is outside the scope of the C
standard.  But as you note, even diagnostics are relied on by tools to
manipulate the referenced files, and changing the file names in the compiler
output would break such tools.

For example, in Emacs Compilation Mode
(http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html)
if diagnostics in a file named "beep\a.c" were introduced by the string
"beep<BEL>.c:" instead, Emacs would no longer be able to open the file.

On the other hand, "beep\a.c" seems like a corner case not worth worrying
about, and since most multibyte encodings (with the exception of ISO 10646)
seem to take care to avoid using control characters for the second and
subsequent bytes, maybe the impact of such filtering wouldn't be as bad as
might at first seem, especially if an option were provided to disable the
filtering.  David Wheeler presents some good arguments in favor of restricting
the set of valid file name characters in his paper on Fixing Unix/Linux/POSIX
Filenames:
http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html


  parent reply	other threads:[~2015-05-28  3:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 23:01 [Bug preprocessor/66318] New: " Keith.S.Thompson at gmail dot com
2015-05-27 23:42 ` [Bug preprocessor/66318] " msebor at gcc dot gnu.org
2015-05-28  0:06 ` Keith.S.Thompson at gmail dot com
2015-05-28  3:20 ` msebor at gcc dot gnu.org [this message]
2015-05-28 23:38 ` miyuki at gcc dot gnu.org
2015-05-29 19:47 ` Keith.S.Thompson at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66318-4-s0Y9JOGwQT@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).