From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#24206: 25.1; Curly quotes generate invalid strings, leading to a segfault Date: Tue, 16 Aug 2016 10:37:39 -0700 Organization: UCLA Computer Science Department Message-ID: <17f39e7e-31d1-62e5-367d-833b957a39e3@cs.ucla.edu> References: <8337m7h1dp.fsf@gnu.org> <83zioffew5.fsf@gnu.org> <83popaf1yz.fsf@gnu.org> <87bn0u3rqc.fsf@linux-m68k.org> <83mvkdg91i.fsf@gnu.org> <8b78f23f-4a4f-e568-b760-3350ca7bb8d3@cs.ucla.edu> <83eg5og4n9.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------43C5A9FCFECE2AF1261B9F31" X-Trace: blaine.gmane.org 1471369099 32180 195.159.176.226 (16 Aug 2016 17:38:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 16 Aug 2016 17:38:19 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 Cc: p.stephani2@gmail.com, johnw@gnu.org, schwab@linux-m68k.org, nicolas@petton.fr, 24206@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 16 19:38:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZiJY-00087A-GA for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Aug 2016 19:38:12 +0200 Original-Received: from localhost ([::1]:43382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZiJY-0001fn-La for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Aug 2016 13:38:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZiJS-0001eM-Io for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2016 13:38:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZiJO-0002I1-Id for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2016 13:38:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZiJO-0002Hw-FP for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2016 13:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bZiJO-0004Rm-Bc for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2016 13:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Aug 2016 17:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24206 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24206-submit@debbugs.gnu.org id=B24206.147136907217078 (code B ref 24206); Tue, 16 Aug 2016 17:38:02 +0000 Original-Received: (at 24206) by debbugs.gnu.org; 16 Aug 2016 17:37:52 +0000 Original-Received: from localhost ([127.0.0.1]:59457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZiJD-0004RO-W6 for submit@debbugs.gnu.org; Tue, 16 Aug 2016 13:37:52 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43272) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZiJC-0004RB-5T for 24206@debbugs.gnu.org; Tue, 16 Aug 2016 13:37:50 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 67692161273; Tue, 16 Aug 2016 10:37:44 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DxcYdhB4w_w9; Tue, 16 Aug 2016 10:37:43 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7756B1612E8; Tue, 16 Aug 2016 10:37:43 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id k5R3zby6rP_a; Tue, 16 Aug 2016 10:37:43 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4E0E9161273; Tue, 16 Aug 2016 10:37:43 -0700 (PDT) In-Reply-To: <83eg5og4n9.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122281 Archived-At: This is a multi-part message in MIME format. --------------43C5A9FCFECE2AF1261B9F31 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: > I preferred to install one of the 2 patches I posted yesterday. Let's not cut the RC now, as unfortunately that patch fails spectacularly= . (I=20 didn't test it yesterday; I tested your other patch, which is obviously b= etter.)=20 To reproduce the problem, run emacs -Q and "C-h f car RET"; Emacs will di= splay=20 "Wrong type argument: integer-or-marker-p, nil" instead of help. The attached patch to emacs-25 fixes the problem. It makes the code funct= ionally=20 equivalent to the other of the 2 patches that you posted yesterday, and i= s=20 simpler. OK to install in emacs-25? --------------43C5A9FCFECE2AF1261B9F31 Content-Type: text/x-diff; name="0001-Fix-wrong-type-argument-bug-with-C-h-f.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Fix-wrong-type-argument-bug-with-C-h-f.patch" =46rom 36a8eec4e8f07724e5ed202b0c68233019975e85 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 16 Aug 2016 10:36:14 -0700 Subject: [PATCH] =3D?UTF-8?q?Fix=3D20=3DE2=3D80=3D98wrong=3D20type=3D20ar= gument=3DE2=3D80=3D99?=3D =3D?UTF-8?q?=3D20bug=3D20with=3D20C-h=3D20f?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * src/doc.c (Fsubstitute_command_keys): Revert previous change. Instead, to fix the core dump, first convert source string to a multibyte temporary if it is not multibyte already. As before, keep the original string if there are no changes (Bug#24206). --- src/doc.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/doc.c b/src/doc.c index 86e1e0d..4f5f7a4 100644 --- a/src/doc.c +++ b/src/doc.c @@ -750,7 +750,7 @@ Otherwise, return a new string. */) unsigned char const *start; ptrdiff_t length, length_byte; Lisp_Object name; - bool multibyte, pure_ascii; + bool multibyte; ptrdiff_t nchars; =20 if (NILP (string)) @@ -763,12 +763,9 @@ Otherwise, return a new string. */) =20 enum text_quoting_style quoting_style =3D text_quoting_style (); =20 + Lisp_Object orig_string =3D string; + string =3D Fstring_make_multibyte (string); multibyte =3D STRING_MULTIBYTE (string); - /* Pure-ASCII unibyte input strings should produce unibyte strings - if substitution doesn't yield non-ASCII bytes, otherwise they - should produce multibyte strings. */ - pure_ascii =3D SBYTES (string) =3D=3D count_size_as_multibyte (SDATA (= string), - SCHARS (string)); nchars =3D 0; =20 /* KEYMAP is either nil (which means search all the active keymaps) @@ -950,11 +947,8 @@ Otherwise, return a new string. */) =20 subst_string: start =3D SDATA (tem); + length =3D SCHARS (tem); length_byte =3D SBYTES (tem); - if (multibyte || pure_ascii) - length =3D SCHARS (tem); - else - length =3D length_byte; subst: nonquotes_changed =3D true; subst_quote: @@ -973,15 +967,11 @@ Otherwise, return a new string. */) } } else if ((strp[0] =3D=3D '`' || strp[0] =3D=3D '\'') - && quoting_style =3D=3D CURVE_QUOTING_STYLE - && multibyte) + && quoting_style =3D=3D CURVE_QUOTING_STYLE) { start =3D (unsigned char const *) (strp[0] =3D=3D '`' ? uLSQM : uRSQM= ); + length =3D 1; length_byte =3D sizeof uLSQM - 1; - if (multibyte || pure_ascii) - length =3D 1; - else - length =3D length_byte; idx =3D strp - SDATA (string) + 1; goto subst_quote; } @@ -1036,7 +1026,7 @@ Otherwise, return a new string. */) } } else - tem =3D string; + tem =3D orig_string; xfree (buf); return tem; } --=20 2.5.5 --------------43C5A9FCFECE2AF1261B9F31--