From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Subject: Re: 23.0.60; Assuming errstring unibyte is incorrect and leads to Emacs crashes
Date: Tue, 26 Aug 2008 13:28:39 -0400 [thread overview]
Message-ID: <87y72ju1mg.fsf@cyd.mit.edu> (raw)
Could someone review the patch submitted with bug#778 for correctness?
I've excerpted part of the bug report below; the full report can be
viewed at
http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=778
Dmitry Dzhus <dima@sphinx.net.ru> wrote:
> Looks like the code of `report_file_error' function at fileio.c assumes
> errstring is unibyte after `code_convert_string_norecord' call.
>
> str = strerror (errorno);
> errstring = code_convert_string_norecord (make_unibyte_string (str,
> strlen (str)),
> Vlocale_coding_system, 0);
>...
> /* System error messages are capitalized. Downcase the initial
> unless it is followed by a slash. */
> if (SREF (errstring, 1) != '/')
> SSET (errstring, 0, DOWNCASE (SREF (errstring, 0)));
>
> That's not always true.
>
> The result of `code_convert_string_norecord' results in a multibyte
> string object when `CODING_FOR_UNIBYTE (Vlocale_coding_system)' is not
> true, that is indicated by code in `decode_coding_object' function from
> coding.c:
>
> if (EQ (dst_object, Qt)
> || (! NILP (CODING_ATTR_POST_READ (attrs))
> && NILP (dst_object)))
> {
> coding->dst_multibyte = !CODING_FOR_UNIBYTE (coding);
>....
>
> Looks like the issue may be resolved replacing a SSET&SREF call at
> `report_file_error' with something multibyte-aware. I've attached a
> one-line patch which does the job. It makes an assertion that a
> downcase and uppercase character both occupy the same amount of bytes.
>
> Using `Fdowncase' function instead also fixes the problem, but at a
> cost of slight overhead (the whole string gets processed, not just the
> first character (this cannot impact performance seriously though, as I
> believe those `errstring' variables are not processed often)) my patch
> does not introduce.
>
> I've tested the patch with several locales (both problematic and
> traditional ones) and couldn't spot any regression introduced with
> this patch.
*** fileio.c.~1.629.~ 2008-08-06 01:41:14.000000000 +0400
--- fileio.c 2008-08-26 02:09:11.000000000 +0400
***************
*** 262,268 ****
/* System error messages are capitalized. Downcase the initial
unless it is followed by a slash. */
if (SREF (errstring, 1) != '/')
! SSET (errstring, 0, DOWNCASE (SREF (errstring, 0)));
xsignal (Qfile_error,
Fcons (build_string (string), Fcons (errstring, data)));
--- 262,268 ----
/* System error messages are capitalized. Downcase the initial
unless it is followed by a slash. */
if (SREF (errstring, 1) != '/')
! CHAR_STRING (DOWNCASE (STRING_CHAR (SDATA(errstring), 0)), SDATA(errstring));
xsignal (Qfile_error,
Fcons (build_string (string), Fcons (errstring, data)));
next reply other threads:[~2008-08-26 17:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-26 17:28 Chong Yidong [this message]
2008-08-27 1:13 ` 23.0.60; Assuming errstring unibyte is incorrect and leads to Emacs crashes Kenichi Handa
2008-08-27 3:20 ` Eli Zaretskii
2008-08-28 0:40 ` Kenichi Handa
2008-08-28 3:20 ` Eli Zaretskii
2008-08-28 5:53 ` Kenichi Handa
2008-08-28 9:23 ` Jason Rumney
2008-08-28 20:43 ` Stephen Berman
2008-08-31 18:36 ` Stefan Monnier
2008-09-01 6:11 ` Richard M. Stallman
2008-09-01 18:22 ` Stefan Monnier
2008-09-02 1:09 ` Richard M. Stallman
2008-09-02 19:56 ` Stefan Monnier
2008-09-03 2:41 ` Richard M. Stallman
2008-09-03 16:09 ` Stefan Monnier
2008-09-04 0:10 ` Richard M. Stallman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y72ju1mg.fsf@cyd.mit.edu \
--to=cyd@stupidchicken.com \
--cc=emacs-devel@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).