From unknown Tue Jun 17 22:20:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47383: [PATCH 2/2] ln: fix memory leaks in do_link() Resent-From: Kamil Dudka Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 25 Mar 2021 10:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47383 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 47383@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16166699024848 (code B ref -1); Thu, 25 Mar 2021 10:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Mar 2021 10:58:22 +0000 Received: from localhost ([127.0.0.1]:37272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPNh0-0001G8-16 for submit@debbugs.gnu.org; Thu, 25 Mar 2021 06:58:22 -0400 Received: from lists.gnu.org ([209.51.188.17]:47732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPNgy-0001G1-MS for submit@debbugs.gnu.org; Thu, 25 Mar 2021 06:58:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPNgy-0000yi-D4 for bug-coreutils@gnu.org; Thu, 25 Mar 2021 06:58:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPNgv-0004EW-Bj for bug-coreutils@gnu.org; Thu, 25 Mar 2021 06:58:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616669894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rl23r9+ofE9urcIEHWZ9UpDZPWGHIAsuJU4pjQ0GLfI=; b=OkIFRB7+400reQY3dy5fLdfNV48JUSOToeU+UGo+cds8u6g8SYgZCBuTlaqNfvJ7Gu1rAz P1jg8Dbx0c284rtz3+2zaML7c/tY15OM/GZQhkXihNPADKkJY4+XdT8Bw5I2WU+2xY7zbD 0vqd6u+u0xrGVEOh2Y4+hZ2P7Wq0mcI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-8rSNZVnlOgSc5zyPVqrg0Q-1; Thu, 25 Mar 2021 06:58:12 -0400 X-MC-Unique: 8rSNZVnlOgSc5zyPVqrg0Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFE3D80D6B4 for ; Thu, 25 Mar 2021 10:57:59 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10A2E17258; Thu, 25 Mar 2021 10:57:58 +0000 (UTC) From: Kamil Dudka Date: Thu, 25 Mar 2021 11:57:56 +0100 Message-Id: <20210325105756.145689-2-kdudka@redhat.com> In-Reply-To: <20210325105756.145689-1-kdudka@redhat.com> References: <20210325105756.145689-1-kdudka@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kdudka@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=216.205.24.124; envelope-from=kdudka@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) * src/ln.c (do_link): Free memory allocated by convert_abs_rel() on all code paths. --- src/ln.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ln.c b/src/ln.c index e79ca5e7ade..368b109daf0 100644 --- a/src/ln.c +++ b/src/ln.c @@ -229,14 +229,14 @@ do_link (char const *source, int destdir_fd, char const *dest_base, if (errno != ENOENT) { error (0, errno, _("failed to access %s"), quoteaf (dest)); - return false; + goto fail; } force = false; } else if (S_ISDIR (dest_stats.st_mode)) { error (0, 0, _("%s: cannot overwrite directory"), quotef (dest)); - return false; + goto fail; } else if (seen_file (dest_set, dest, &dest_stats)) { @@ -245,7 +245,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base, error (0, 0, _("will not overwrite just-created %s with %s"), quoteaf_n (0, dest), quoteaf_n (1, source)); - return false; + goto fail; } else { @@ -274,7 +274,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base, { error (0, 0, _("%s and %s are the same file"), quoteaf_n (0, source), quoteaf_n (1, dest)); - return false; + goto fail; } } @@ -285,7 +285,10 @@ do_link (char const *source, int destdir_fd, char const *dest_base, fprintf (stderr, _("%s: replace %s? "), program_name, quoteaf (dest)); if (!yesno ()) - return true; + { + free(rel_source); + return true; + } } if (backup_type != no_backups) @@ -304,7 +307,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base, { error (0, rename_errno, _("cannot backup %s"), quoteaf (dest)); - return false; + goto fail; } force = false; } @@ -397,6 +400,10 @@ do_link (char const *source, int destdir_fd, char const *dest_base, free (backup_base); free (rel_source); return link_errno <= 0; + +fail: + free (rel_source); + return false; } void -- 2.26.3 From unknown Tue Jun 17 22:20:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47383: [PATCH 2/2] ln: fix memory leaks in do_link() Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 25 Mar 2021 16:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47383 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Kamil Dudka Cc: 47383@debbugs.gnu.org Received: via spool by 47383-submit@debbugs.gnu.org id=B47383.161668920615796 (code B ref 47383); Thu, 25 Mar 2021 16:21:01 +0000 Received: (at 47383) by debbugs.gnu.org; 25 Mar 2021 16:20:06 +0000 Received: from localhost ([127.0.0.1]:39419 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPSiM-00046i-2Q for submit@debbugs.gnu.org; Thu, 25 Mar 2021 12:20:06 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37184) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPSiJ-000462-6T for 47383@debbugs.gnu.org; Thu, 25 Mar 2021 12:20:04 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1F48C1600BC; Thu, 25 Mar 2021 09:19:57 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id JxGmiHIpnsI4; Thu, 25 Mar 2021 09:19:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 77A5F160118; Thu, 25 Mar 2021 09:19:56 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id E8ZTgeAH4oTD; Thu, 25 Mar 2021 09:19:56 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 519691600BC; Thu, 25 Mar 2021 09:19:56 -0700 (PDT) References: <20210325105756.145689-1-kdudka@redhat.com> <20210325105756.145689-2-kdudka@redhat.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <8da64c81-5093-88bc-3eb0-d5ffffea5b00@cs.ucla.edu> Date: Thu, 25 Mar 2021 09:19:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210325105756.145689-2-kdudka@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Thanks, I installed that. I then changed "free(" to "free (" as per GNU style. From unknown Tue Jun 17 22:20:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47383: [PATCH 2/2] ln: fix memory leaks in do_link() Resent-From: Kamil Dudka Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 25 Mar 2021 19:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47383 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 47383@debbugs.gnu.org X-Debbugs-Original-Cc: bug-coreutils@gnu.org, 47383@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161669886731900 (code B ref -1); Thu, 25 Mar 2021 19:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 Mar 2021 19:01:07 +0000 Received: from localhost ([127.0.0.1]:39634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPVEA-0008IS-U0 for submit@debbugs.gnu.org; Thu, 25 Mar 2021 15:01:07 -0400 Received: from lists.gnu.org ([209.51.188.17]:57968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPVE6-0008I9-8H for submit@debbugs.gnu.org; Thu, 25 Mar 2021 15:01:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPVE5-0007q6-SZ for bug-coreutils@gnu.org; Thu, 25 Mar 2021 15:01:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPVE4-0001Xg-6K for bug-coreutils@gnu.org; Thu, 25 Mar 2021 15:01:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616698858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iJJ7bwB4indzlaaoITsm/UWIhOXU5ZcjpPAW/2mxlZ0=; b=INMg/YQgBv+Fc228c0Nn83lqff6JOOY+F1eejfX970lF2NUj37nsYz/F3CZwf84V7SY3Lb lCsAn+dZGzLQ2q6LKb3CnWCTxVAtgsfnHb3N9XJXSR2SW4IKxz0aR6T6oxcq9pJQPHHmh+ LPfHQ2SPraTqL8mC0BSfZPH49Ls8e00= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-wUhR4uetOCi-X4aA3k_ykw-1; Thu, 25 Mar 2021 15:00:56 -0400 X-MC-Unique: wUhR4uetOCi-X4aA3k_ykw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9AA0107ACCD; Thu, 25 Mar 2021 19:00:55 +0000 (UTC) Received: from nbkamil.localnet (unknown [10.40.192.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 167315D6D5; Thu, 25 Mar 2021 19:00:54 +0000 (UTC) From: Kamil Dudka Date: Thu, 25 Mar 2021 20:00:54 +0100 Message-ID: <2023595.OBFZWjSADL@nbkamil> In-Reply-To: <8da64c81-5093-88bc-3eb0-d5ffffea5b00@cs.ucla.edu> References: <20210325105756.145689-1-kdudka@redhat.com> <20210325105756.145689-2-kdudka@redhat.com> <8da64c81-5093-88bc-3eb0-d5ffffea5b00@cs.ucla.edu> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kdudka@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: pass client-ip=63.128.21.124; envelope-from=kdudka@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) On Thursday, March 25, 2021 5:19:56 PM CET Paul Eggert wrote: > Thanks, I installed that. I then changed "free(" to "free (" as per GNU > style. Thank you for incorporating both the patches. Kamil From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 30 20:27:55 2021 Received: (at control) by debbugs.gnu.org; 31 Oct 2021 00:27:55 +0000 Received: from localhost ([127.0.0.1]:58656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgyhX-0005K6-7W for submit@debbugs.gnu.org; Sat, 30 Oct 2021 20:27:55 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgyhV-0005Jt-Cs for control@debbugs.gnu.org; Sat, 30 Oct 2021 20:27:54 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 234C81600EB for ; Sat, 30 Oct 2021 17:27:47 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tk3sfitSTyB8 for ; Sat, 30 Oct 2021 17:27:46 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 89FD51600FC for ; Sat, 30 Oct 2021 17:27:46 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZbQmVBxcOr9a for ; Sat, 30 Oct 2021 17:27:46 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6B5741600EB for ; Sat, 30 Oct 2021 17:27:46 -0700 (PDT) Message-ID: <33111315-2911-72a5-f403-ab7fabc4a04b@cs.ucla.edu> Date: Sat, 30 Oct 2021 17:27:46 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Content-Language: en-US To: control@debbugs.gnu.org From: Paul Eggert Organization: UCLA Computer Science Department Subject: coreutils bug maintenance Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 47383 close 42135