From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26892 invoked by alias); 26 Oct 2015 03:57:56 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 26881 invoked by uid 89); 26 Oct 2015 03:57:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: plane.gmane.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 26 Oct 2015 03:57:54 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZqYuq-0001l4-90 for cygwin@cygwin.com; Mon, 26 Oct 2015 04:57:48 +0100 Received: from 76-217-5-154.lightspeed.irvnca.sbcglobal.net ([76.217.5.154]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 26 Oct 2015 04:57:48 +0100 Received: from mark by 76-217-5-154.lightspeed.irvnca.sbcglobal.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 26 Oct 2015 04:57:48 +0100 To: cygwin@cygwin.com From: Mark Geisert Subject: Re: mkshortcut (cygutils-1.4.14) free error Date: Mon, 26 Oct 2015 10:08:00 -0000 Message-ID: References: <1445135414.3384650.413058409.46BC94AD@webmail.messagingengine.com> <1445823930.241438.419951441.109BA262@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00445.txt.bz2 Anthony Heading writes: > I see the cygutils package has been orphaned, perhaps explaining the > lack of response to the below. > A related question then is that the vanilla mkshortcut built from the > latest source package does not > seem to perfectly match the behaviour of the binary. Is there any way > to review or reproduce how > the binary package was built, or any other way to verify that the source > and binaries do match? Unfortunately I have no answers for your good questions above. But... > On Sat, Oct 17, 2015, at 10:30 PM, Anthony Heading wrote: > > Seems free() is being called on an adjusted pointer, causing general > > misbehaviour. A minimal patch below. [...sorry for deletions within the patch; trying to satisfy gmane...] > > - char *buf_str, *tmp_str; > > + char *buf_str, *tmp_str, *base_str; [...] > > buf_str = xstrndup (opts.target_arg, strlen(opts.target_arg)); > > + base_str = buf_str; > > tmp_str = buf_str; ...if tmp_str is not modified after the above line, ... > > tmp = strlen (buf_str) - 1; > > while (strrchr (buf_str, '/') == (buf_str + tmp)) > > -504,7 +505,7 > > buf_str++; > > } > > link_name = xstrndup (tmp_str, strlen (tmp_str)); > > - free (buf_str); > > + free (base_str); ...then "free(tmp_str);" should solve the original issue without having to define a new variable base_str. I didn't look at the complete original code, only the patch that you posted, but hopefully this points to a "more minimal" fix if you agree it's solid. ..mark -- 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