all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: rms@gnu.org
Cc: 21602-done@debbugs.gnu.org
Subject: bug#21602: 25.0.50; coding system seg fault
Date: Sat, 03 Oct 2015 13:48:38 +0300	[thread overview]
Message-ID: <83fv1s448p.fsf@gnu.org> (raw)
In-Reply-To: <E1ZiBlk-0000xd-HZ@fencepost.gnu.org>

> From: Richard Stallman <rms@gnu.org>
> CC: 21602@debbugs.gnu.org
> Date: Fri, 02 Oct 2015 21:37:48 -0400
> 
> I can reproduce the failure in emacs -Q with the code below.  The code
> in my-send-1 is responsible for passing specifying the coding system,
> but even if that value is wrong, write-region should not crash.

Thanks.  For the record, here's a simpler way of triggering the same
crash:

  emacs -Q

Type in *scratch*:

  (let ((coding-system-for-write (intern "\"us-ascii\"")))
    (write-region 1 10 "/tmp/SEGV"))

Evaluate this sexp, and you get the same segfault.

The problem here is that we don't check the validity of the
coding-system the user forced on us, until it's too late.

I found a couple more cases of missing validation like this one, and
fixed them all in commit 658f2c4.  The diffs are below.

diff --git a/src/fileio.c b/src/fileio.c
index e4b255a..65aaf57 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3470,7 +3470,10 @@ by calling `format-decode', which see.  */)
       mtime = time_error_value (save_errno);
       st.st_size = -1;
       if (!NILP (Vcoding_system_for_read))
-	Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
+	{
+	  CHECK_CODING_SYSTEM (Vcoding_system_for_read);
+	  Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
+	}
       goto notfound;
     }
 
@@ -4526,6 +4529,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   else if (!NILP (Vcoding_system_for_write))
     {
       val = Vcoding_system_for_write;
+      CHECK_CODING_SYSTEM (val);
       if (coding_system_require_warning
 	  && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
 	/* Confirm that VAL can surely encode the current region.  */
@@ -4574,6 +4578,9 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
 	  using_default_coding = 1;
 	}
 
+      if (!NILP (val))
+	CHECK_CODING_SYSTEM (val);
+
       if (! NILP (val) && ! force_raw_text)
 	{
 	  Lisp_Object spec, attrs;






  reply	other threads:[~2015-10-03 10:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02  2:32 bug#21602: 25.0.50; coding system seg fault Richard Stallman
2015-10-02  7:04 ` Eli Zaretskii
2015-10-03  1:37   ` Richard Stallman
2015-10-03 10:48     ` Eli Zaretskii [this message]
2015-10-03 11:30       ` Andreas Schwab
2015-10-03 11:51         ` Eli Zaretskii
2015-10-03 12:14           ` Andreas Schwab
2015-10-03 12:42             ` Eli Zaretskii
2015-10-03 12:50               ` Andreas Schwab
2015-10-03 13:15                 ` Eli Zaretskii
2015-10-03 14:19                   ` Eli Zaretskii
2015-10-03 15:00                     ` Andreas Schwab
2015-10-03 15:26                       ` Eli Zaretskii
2015-10-03 16:09                         ` Andreas Schwab
2015-10-03 16:11                           ` Eli Zaretskii
2015-10-03 17:22                     ` Zack Piper
2015-10-03 18:16                       ` Andreas Schwab
2015-10-03 12:07       ` Andreas Schwab
2015-10-03 12:15         ` Eli Zaretskii
2015-10-03 12:25           ` Andreas Schwab
2015-10-03 12:36             ` Eli Zaretskii
2015-10-03 12:48               ` Andreas Schwab
2015-10-03 13:14                 ` Eli Zaretskii
2015-10-03  1:37   ` Richard Stallman
2015-10-03 10:49     ` Eli Zaretskii

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=83fv1s448p.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=21602-done@debbugs.gnu.org \
    --cc=rms@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.