unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 8435@debbugs.gnu.org
Subject: bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts
Date: Fri, 08 Apr 2011 11:58:44 +0300	[thread overview]
Message-ID: <83vcypt8zf.fsf@gnu.org> (raw)
In-Reply-To: <4D9E21FB.70802@cs.ucla.edu>

> Date: Thu, 07 Apr 2011 13:43:39 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: 8435@debbugs.gnu.org
> 
> > It also supported %c format for converting a multibyte character to
> > its integer representation.
> 
> This problem should be OK too.  I manually inspected all the places
> that used the %c format.  All but one of them used %c only to convert
> unibyte characters, so they're OK.  The only exception was in
> charset_iso_charset_parameter, and I modified that function to convert
> the multibyte character before passing it as a string to 'error'.

But we are losing a valuable feature this way, I think.  From now on,
any code that needs to use %c for displaying a character codepoint
will need to convert it manually before calling the message functions.

Taking a step back, this issue is about possible bugs when int and
EMACS_INT data types are mixed up in the calls to functions that could
either call doprnt or printf and its ilk.  So I think it would be
better to fix these problems as follows:

  . Introduce a printf format conversion specifier for converting an
    EMACS_INT data type.

  . Fix all the direct and indirect callers of doprnt to use this new
    specifier when the argument is an EMACS_INT.

  . Fix doprnt to avoid overflow when EMACS_INT is a 64-bit type, if
    it could overflow.  (I don't see such a danger, but maybe I
    overlook something.)

You already did the first two.  So I think what my suggestion boils
down to fixing doprnt (if needed) instead of introducing vsnprintf,
and then all the additional problems caused by that introduction will
be gone.

So could you please tell what are the downsides of keeping doprnt
instead of introducing vsnprintf?

> Another issue has come up in further static analysis.  The vsnprintf
> API does not work for strings longer than INT_MAX bytes.  For
> vmessage's use of vsnprintf this is OK, since (for other reasons) a
> frame title can't be that long.  However, for verror this is an
> arbitrary limitation on typical 64-bit hosts.  I'll look into this,
> and plan to propose a further patch to handle it.

I don't think we have any reason to support strings longer than
INT_MAX in these functions.  They are used to display messages in the
echo area/minibuffer, so they can hardly be close to INT_MAX anyway.
We could simply document that and move on.  For bullet-proof code, we
could even check the length and truncate the string before passing it
to verror or its subroutines.

I also don't think we should remove message_nolog, even if it's
currently unused.  It's a useful function.  If someone feels badly
about having dead code, we could #ifdef it away, although I don't
think it matters for such a short function.





  reply	other threads:[~2011-04-08  8:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 19:59 bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts Paul Eggert
     [not found] ` <handler.8435.B.130211997010029.ack@debbugs.gnu.org>
2011-04-07  7:33   ` Paul Eggert
2011-04-07 12:29     ` Andy Moreton
2011-04-07 18:31     ` Eli Zaretskii
2011-04-07 20:43       ` Paul Eggert
2011-04-08  8:58         ` Eli Zaretskii [this message]
2011-04-08 23:34           ` Paul Eggert
2011-04-09  7:20             ` Eli Zaretskii
2011-04-09 18:24               ` Paul Eggert
2011-04-09 18:32                 ` Eli Zaretskii
2011-04-09 19:39                   ` Paul Eggert
2011-04-09 20:21                     ` Eli Zaretskii
2011-04-10  3:52                       ` Stefan Monnier
2011-04-10  5:19                         ` Eli Zaretskii
2011-04-11  1:44                           ` Stefan Monnier
2011-04-11  2:54                             ` Eli Zaretskii
2011-04-10 17:03                       ` Paul Eggert
2011-04-09 19:28                 ` Eli Zaretskii
2011-04-09 19:43                   ` Paul Eggert
2011-04-08 23:37           ` Paul Eggert
2011-04-25  0:59             ` Daniel Colascione
2011-04-25  6:42               ` 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

  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=83vcypt8zf.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=8435@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).