zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: buffer overflow detected ***: ../Src/zsh terminated
Date: Mon, 2 Apr 2007 11:48:16 +0100	[thread overview]
Message-ID: <20070402114816.5ececb9e.pws@csr.com> (raw)
In-Reply-To: <20070401192942.GP29754@solemn.turbinal>

Alexey Tourbin <at@altlinux.ru> wrote:
> On Fri, Mar 30, 2007 at 06:01:45PM +0400, Alexey Tourbin wrote:
> > Here is what happens with most recent zsh snapshot.
> > 
> > ./D07multibyte.ztst: starting.
> > Testing multibyte with locale en_US.UTF-8
> > *** buffer overflow detected ***: ../Src/zsh terminated
> 
> git-bisect blames this change:
> 
> commit c28114a1fadd68432443c3a4b3822efdd11dbad2
> Author: Peter Stephenson
> Date:   Sat Feb 10 22:12:59 2007 +0000
> 
>     fix metafication of ${(#)x}

It might wll be this stupidity.  I can't rely on the number of digits
in an unsigned int, hence I've added the "&", too.

Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.76
diff -u -r1.76 subst.c
--- Src/subst.c	25 Feb 2007 23:41:04 -0000	1.76
+++ Src/subst.c	2 Apr 2007 10:46:07 -0000
@@ -1199,10 +1199,11 @@
 	return NULL;
 #ifdef MULTIBYTE_SUPPORT
     if (isset(MULTIBYTE) && ires > 127) {
-	char buf[10];
+	/* '\\' + 'U' + 8 bytes of character + '\0' */
+	char buf[11];
 
 	/* inefficient: should separate out \U handling from getkeystring */
-	sprintf(buf, "\\U%.8x", (unsigned int)ires);
+	sprintf(buf, "\\U%.8x", (unsigned int)ires & 0xFFFFFFFFu);
 	ptr = getkeystring(buf, &len, GETKEYS_BINDKEY, NULL);
     }
     if (len == 0)


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


  reply	other threads:[~2007-04-02 10:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-30 14:01 Alexey Tourbin
2007-04-01 19:29 ` Alexey Tourbin
2007-04-02 10:48   ` Peter Stephenson [this message]
2007-04-03 10:47     ` Alexey Tourbin

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=20070402114816.5ececb9e.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /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.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).