From unknown Mon Jun 23 20:17:28 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24244 <24244@debbugs.gnu.org> To: bug#24244 <24244@debbugs.gnu.org> Subject: Status: dd: protect against same file in input,output Reply-To: bug#24244 <24244@debbugs.gnu.org> Date: Tue, 24 Jun 2025 03:17:28 +0000 retitle 24244 dd: protect against same file in input,output reassign 24244 coreutils submitter 24244 puggy severity 24244 wishlist tag 24244 wontfix thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 16 11:30:01 2016 Received: (at submit) by debbugs.gnu.org; 16 Aug 2016 15:30:01 +0000 Received: from localhost ([127.0.0.1]:59418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZgJV-000899-A0 for submit@debbugs.gnu.org; Tue, 16 Aug 2016 11:30:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39832) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZefx-0005HT-Ug for submit@debbugs.gnu.org; Tue, 16 Aug 2016 09:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZefp-0004wx-13 for submit@debbugs.gnu.org; Tue, 16 Aug 2016 09:45:00 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZefo-0004wc-UV for submit@debbugs.gnu.org; Tue, 16 Aug 2016 09:44:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZefm-0001AT-MT for bug-coreutils@gnu.org; Tue, 16 Aug 2016 09:44:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZefj-0004v0-H4 for bug-coreutils@gnu.org; Tue, 16 Aug 2016 09:44:54 -0400 Received: from mout.gmx.net ([212.227.17.22]:54653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZefj-0004un-6G for bug-coreutils@gnu.org; Tue, 16 Aug 2016 09:44:51 -0400 Received: from usbarch64 ([213.33.16.50]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MTeVY-1biYca44tU-00QWpA for ; Tue, 16 Aug 2016 15:44:49 +0200 Date: Tue, 16 Aug 2016 15:44:35 +0000 From: puggy To: bug-coreutils@gnu.org Subject: bug: dd deletes file Message-ID: <20160816154435.GB699@usbarch64> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.6.2 (2016-07-01) X-Provags-ID: V03:K0:HEbHR+Yi309sLN2FM/fxWLws8lx2RooQ1Cs1WR8PP2pBbyZNS7J KE83CvewFGoKKDjqPKfvoAaV7dipbxSg55PI7BSK/2zmyuN4ZM6EL1zu4qHN6pOKxPoYyiW 8NVkrlboMJNVtZwFuCN0Oazoy9iY0NaD0kQhRLxP2eqt/KSEnmthPLUOBQeN7xBpBgJwocp 1EGCsGZ7sqfmVR4RwzlCw== X-UI-Out-Filterresults: notjunk:1;V01:K0:LSyFvLJeXe0=:PmZf3iCJQ4LhvPODnKSIhJ +eTY6WmKhKMG2Ow97zcR4tFkA0NKnqccA6+O78+DyJV6pOD9Z7Xo3tYd5EUgnqjMuYTuTkp0q CABEocEZLACIldNbyb8CAeLJs3gH9771PHzTSlhP+r1lL05ItCUktud/vETG/2bokxOo7XNIE X+QVRL6V5DiVcoUCR4ihOdDnMtGqGWa97Dd01odPwCx2Pk7+NO1lGWlc/VGTZv8vf5k5GInv7 IU2FBcEvD5gSmlC4VHrNeQoA91T+5uPyJUmN6pi+G3pdmgTMFzkUYv6efiSktDy+i+2L+XP5+ pUros2ibAOO4rAQR62JMvgMfFB9fDTd3ANyrCxI+SVKmfngelNxXJvTL01bLG/X/B2ybMTOfw bwG+H+eO7q1vCmXoHgTEGGeeDTJ+RtEU5gcWF+k8XhlvfjoewskLBK2augVbH1OtB2tqjLxzp LrGYMEKhy9ihpTFngCv97joJIzcINrbS+Aku6RKyg/JAmIg4Pt3hGGTNFf3gFoORH+pOFZBgI V2qdB+26CGNSJ1Dz3BeuzEN3Qa18HcISngdHD9K27btCZWCM45B9IxTuniL9V6UyCscoBsL3J EakVm50eJSNCAdTNjdn73fkepTlRS96pmf5ZupLFziD1hdV5fcHz+bD5+3MosbIG8VZEarXGM eiDngoO+LZupLGJA6xuyGp41x9ZcTHZ1I6vLT8u0e8zMObPrfBPDiXa1lc1PW043XcQ6ezMhK nmo6aAYpxQB1ksBUJlUefAgTIgU2iE3HS3TKAwbdkQ7lgkL0VaBNxegEO2U= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 16 Aug 2016 11:30:00 -0400 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: -4.1 (----) i've just found a bug in "dd". by mistakes i used the same input and output file. dd said it wrote 0 bytes, but what it actually did is overwrite the file and setting it back to zero. doing so, dd deleted a 4.3G file in a fraction of a blink. luckily i can download the file again. but before it took me 2 hours to download this file. now i have to download it again, wait for another 2 hours and i can't work for this time. 2 hours for a little mistake. 4 hours time loss! this can't happen. mistakes happen. by simple logics it doesn't make sense to delete a file, just because input and output file are the same. also there is barely anything easier to check for. please find some solution for it. if it is intentional, make an option for it. this way you can also shorten the command. otherwise if input and output are the same, warn the user! From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 16 12:03:57 2016 Received: (at 24244) by debbugs.gnu.org; 16 Aug 2016 16:03:57 +0000 Received: from localhost ([127.0.0.1]:59432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZgqL-00028x-EB for submit@debbugs.gnu.org; Tue, 16 Aug 2016 12:03:57 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:45254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZgqJ-00028o-K0 for 24244@debbugs.gnu.org; Tue, 16 Aug 2016 12:03:56 -0400 Received: from [192.168.1.80] (unknown [109.77.20.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 451334AE1; Tue, 16 Aug 2016 17:03:54 +0100 (IST) Subject: Re: bug#24244: bug: dd deletes file To: puggy , 24244@debbugs.gnu.org References: <20160816154435.GB699@usbarch64> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <57B33969.8040106@draigBrady.com> Date: Tue, 16 Aug 2016 17:03:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20160816154435.GB699@usbarch64> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 24244 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: 0.0 (/) On 16/08/16 16:44, puggy wrote: > i've just found a bug in "dd". > > by mistakes i used the same input and output file. > dd said it wrote 0 bytes, but what it actually did > is overwrite the file and setting it back to zero. > doing so, dd deleted a 4.3G file in a fraction of > a blink. > > luckily i can download the file again. but before > it took me 2 hours to download this file. now i > have to download it again, wait for another 2 > hours and i can't work for this time. 2 hours for > a little mistake. 4 hours time loss! > > this can't happen. mistakes happen. by simple > logics it doesn't make sense to delete a file, > just because input and output file are the same. > also there is barely anything easier to check > for. > > please find some solution for it. if it is > intentional, make an option for it. this way > you can also shorten the command. otherwise > if input and output are the same, warn the user! Well dd is a low level tool so we have to be careful to not preclude operations which may be valid in some cases. For example one might definitely want to read/write the same device. Also conv=notrunc might be useful with regular files to fully allocate holes etc. Maybe we could: if (IS_REG() && conv!=notrunc) disallow input==output From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 02:31:11 2018 Received: (at 24244) by debbugs.gnu.org; 28 Oct 2018 06:31:11 +0000 Received: from localhost ([127.0.0.1]:46278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGebO-0005XU-MX for submit@debbugs.gnu.org; Sun, 28 Oct 2018 02:31:10 -0400 Received: from mail-pl1-f169.google.com ([209.85.214.169]:42447) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGebM-0005Rb-KH; Sun, 28 Oct 2018 02:31:08 -0400 Received: by mail-pl1-f169.google.com with SMTP id t6-v6so2302979plo.9; Sat, 27 Oct 2018 23:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=eIEuSOQUSrdyztlj8DHpsxOtDIvRhdbbsF+/HM5vEgc=; b=q6NlBR3hoNKGix0dul4k84ylPcWQfAWnqUChiDQcEFHTyhFiKbkK/egQTHqUKLfs+f LWmapUAfK16BTg1IXF+XEf43G6iEYjvd3sI0iWJ4SsRBEQ5Q0tHdzDBlbk3Of4hnBJ9x fBvhfU/M0d7BWM/tCSckdDm77GcS4XSJ/aB3t+ZLRffnLaEAJp4aqlNba1UzyOp62hki JDy3/J20zAA/V0K+njVCVxAutVCmAUfmENRY8TP9DQyE/AdzuwwXVQdZvhWyHsGq1kS3 9vRJKOdLzis3qoY6lhEsLeEvGd/MUHVvxtikQ7Yl5jEkALk/4kEd4g5xgJJ3tkS2YTth wmSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=eIEuSOQUSrdyztlj8DHpsxOtDIvRhdbbsF+/HM5vEgc=; b=ZsaaTei0F5kXhq7QrnGxZdtYPExoOhiBKcVEZn0Ba0kRL1jNlgfBMw1QgavRAYGRea ZEjpW5FEXPy850RGVqJsfSjj9lvV0PK1WpJZP7FYTgNwcoDRuW/lLskmqqUW2KnOGpWU zXwrVWSb6c3RVmEt9NyAF04BLMDOmjO4n121aFeViCf7b2GuTeuuS+DXAYxmMfpcOR50 guAymD+PQEmk1RmI+yEdyiwH5Wi/rxPMPiwk0zAatAHeJC+jopxDIfYMx3zv2PMjF13m Y2TJ3LmJPHCYnHGYzAzWiqa/5IihmqFFVrG22eg8VQ5cumwJn5LIooQFzXQrQGPeFZ7q 4Evg== X-Gm-Message-State: AGRZ1gK5FgTXs6dQ9gHZlhKJ1SP43Qydon+Y17ZcnjxySWaEdFGt8D6K o8tVOWSrRhNB0aYmNhQCAus+8/KtT8U= X-Google-Smtp-Source: AJdET5fnyNSok0/Za4v76YPhaPQQ7VK9vZZtysDISq+/Wd25QaAzTcIkqleS0lhmREWEr4K+Jx8Ulg== X-Received: by 2002:a17:902:70c4:: with SMTP id l4-v6mr9449950plt.194.1540708262270; Sat, 27 Oct 2018 23:31:02 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id o12-v6sm25467440pfh.20.2018.10.27.23.31.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 23:31:01 -0700 (PDT) Subject: Re: bug#24244: bug: dd deletes file To: 24244@debbugs.gnu.org References: <20160816154435.GB699@usbarch64> <57B33969.8040106@draigBrady.com> From: Assaf Gordon Message-ID: <4fe13c98-6555-8100-9e45-03f4aabb7bfb@gmail.com> Date: Sun, 28 Oct 2018 00:30:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <57B33969.8040106@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 24244 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: -1.0 (-) retitle 24244 dd: protect against same file in input,output severity 24244 wishlist tags 24244 wontfix close 24244 stop (triaging old bugs) On 2016-08-16 10:03 a.m., Pádraig Brady wrote: > On 16/08/16 16:44, puggy wrote: >> by mistakes i used the same input and output file. >> dd said it wrote 0 bytes, but what it actually did >> is overwrite the file and setting it back to zero. >> doing so, dd deleted a 4.3G file in a fraction of >> a blink. [....] >> please find some solution for it. if it is >> intentional, make an option for it. this way >> you can also shorten the command. otherwise >> if input and output are the same, warn the user! > > Well dd is a low level tool so we have to be careful > to not preclude operations which may be valid in some cases. > For example one might definitely want to read/write the same device. With no further comments in 2 years, I'm closing this bug. Discussion can continue by replying to this thread. -assaf From unknown Mon Jun 23 20:17:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 25 Nov 2018 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator