X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:mime-version:to:subject
	:references:in-reply-to:content-type; q=dns; s=default; b=lU8NvJ
	yluZhi5SNbgEJS4hSEW+w2eHgwIb6YnuBQ3ljW81qvJVVPt4VH8QzNq7691z4c/L
	17/RFR0gKIZfDmwXRui+oVv3LsOU7YLmZZ3ZodVJQEE3EF8ZDyQnqGe+PPE0UbDq
	HAsEfrKGjq9aVHzIK6B/+gkKbp+WfTQ+vUqsA=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:mime-version:to:subject
	:references:in-reply-to:content-type; s=default; bh=xbd1B4BNBGkZ
	j9q0DDRpuBuKxOc=; b=lkjSANDByV0an4Glc0LOkPytP7AG9rO80JHz9FPWpxt9
	60L3lBCVnwo3ZplfbrWlj+7ymhP09BEgYgt/o6TFtMrYdZJAiQ6VLLgHb9GY+x1p
	qY54OvkrWrZASJsvcCizhBQOdSlmew+xBEy0nuQxvXGHTisTmupnY+JXPVC1E+M=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_50,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,RDNS_NONE autolearn=no version=3.3.1
X-Yahoo-SMTP: u.JgLvyswBBMp9ZJJfsX14qmYb3T2ivhMAr6OupnxLpNQEFZ9g--
X-Rocket-Received: from [192.168.1.72] (jon.turney@109.155.7.202 with plain)        by smtp830.mail.ird.yahoo.com with SMTP; 28 Jul 2013 14:46:46 -0700 PDT
Message-ID: <51F59159.6050005@dronecode.org.uk>
Date: Sun, 28 Jul 2013 22:47:05 +0100
From: Jon TURNEY <jon.turney@dronecode.org.uk>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: setup-x86_64: postinstall errors: Package bash 1, Package a2ps 2 and xinit 134
References: <CADex0xx+uY6Y8ngZ3tUsYr+KPi0t0+H+H7X-civ-iq0diuJfZw@mail.gmail.com>	<51EE0951.90007@users.sourceforge.net>	<51EEC7F2.5000402@cwilson.fastmail.fm>	<20130723184615.GK9689@calimero.vinschen.de>	<51EED4B4.7000908@cwilson.fastmail.fm>	<20130723192342.GM9689@calimero.vinschen.de>	<51EFD0EB.6030804@cwilson.fastmail.fm>	<1358868658.20130724173406@mtu-net.ru> <CADex0xynZvSvXCZ7TNFoqO-djtijKcNSvibVnYyO4KEwTftirg@mail.gmail.com>
In-Reply-To: <CADex0xynZvSvXCZ7TNFoqO-djtijKcNSvibVnYyO4KEwTftirg@mail.gmail.com>
Content-Type: multipart/mixed; boundary="------------060502000701090506050301"
X-Virus-Found: No

--------------060502000701090506050301
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 25/07/2013 05:24, Kenneth Wolcott wrote:
>   I downloaded a fresh setup-x86_64.exe from cygwin.com and then ran
> the update again.
> 
>   Now I get only this postinstall error:
> 
>   Package: xinit
>     xinit.sh exit code 134
I can reproduce this problem, so I had a go at investigating and fixing it.

mkshortcut appears to exiting with SIGABRT in free(), which suggests some heap
corruption, which I managed to track down after a bit of work with dmalloc.

This appears to be a long standing bug, which for some reason manifests itself
more severely on x86_64.

xstrncat() does not allow for the terminating null byte in the memory
allocation it makes.  strncat(dest, src, n) writes n+1 bytes to dest (n from
src plus the terminating null byte, which is always appended).  So, the size
of dest must be at least strlen(dest)+n+1.  Currently only strlen(dest)+n
bytes are allocated.

Trivial patch attached.


--------------060502000701090506050301
Content-Type: text/plain; charset=windows-1252;
 name="cygutils-strncat.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="cygutils-strncat.patch"

--- origsrc/cygutils-1.4.12/src/mkshortcut/mkshortcut.c	2013-04-28 00:17:56.000000000 +0100
+++ src/cygutils-1.4.12/src/mkshortcut/mkshortcut.c	2013-07-28 22:36:54.890625000 +0100
@@ -394,7 +394,7 @@ xstrndup (const char *string, size_t n)
 static char *
 xstrncat (char **dest, const char *add, size_t n)
 {
-  size_t len = strlen (*dest) + n;
+  size_t len = strlen (*dest) + n + 1;
   char *s = (char *) realloc (*dest, len * sizeof (char));
   if (!s)
   {


--------------060502000701090506050301
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------060502000701090506050301--
