X-Recipient: archive-cygwin AT delorie DOT 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:to:from:subject:date:message-id:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=wlvrrVcRDlineO8IyME88lEVzyTQuwJrndh8Nh4p87MYTeKqWo5h0 kVErRqhiaUjyGMac50s984q84d37XcUswlhQf7377fIYkHPbQ7CFWah51E7bZ1PS Rn7r1J084hERNSV2pxa1tni/tf/vZAksXpIBE3XQ3XnBXUJCDdV5Fs= 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:to:from:subject:date:message-id:references :mime-version:content-type:content-transfer-encoding; s=default; bh=gW6N6D822RyHABQJd9og6pKjjZY=; b=AYOQ173IVD2u+oNe3YDrkTi+7sfH q/+EahEa6ulFTAoKTkfr9Kyyhuz/L9yjJunwinHDojpTbGf0GPzvCHSm38yMWpGH kbrD5fjuGuH1G6PtFxsueMVG1c/carQOMvlntbakhzsoW02ad+PiFNWcsgwQo9s+ W6fVsxaLxdCWJ1Q= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 To: cygwin AT cygwin DOT com From: Mark Geisert Subject: Re: mkshortcut (cygutils-1.4.14) free error Date: Mon, 26 Oct 2015 03:57:42 +0000 (UTC) Lines: 43 Message-ID: References: <1445135414 DOT 3384650 DOT 413058409 DOT 46BC94AD AT webmail DOT messagingengine DOT com> <1445823930 DOT 241438 DOT 419951441 DOT 109BA262 AT webmail DOT messagingengine DOT 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 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