GNU bug report logs - #74452
sed -i --follow-symlinks fails in i586 with large paths

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: sed; Reported by: daniel.garcia@HIDDEN; dated Thu, 21 Nov 2024 04:25:02 UTC; Maintainer for sed is bug-sed@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 Nov 2024 04:24:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 20 23:24:22 2024
Received: from localhost ([127.0.0.1]:48681 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tDyju-0002ml-4c
	for submit <at> debbugs.gnu.org; Wed, 20 Nov 2024 23:24:22 -0500
Received: from lists.gnu.org ([209.51.188.17]:54012)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <daniel.garcia@HIDDEN>) id 1tDkUV-0003Vk-Kx
 for submit <at> debbugs.gnu.org; Wed, 20 Nov 2024 08:11:32 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <daniel.garcia@HIDDEN>)
 id 1tDkUT-0007go-Rx
 for bug-sed@HIDDEN; Wed, 20 Nov 2024 08:11:29 -0500
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <daniel.garcia@HIDDEN>)
 id 1tDkUS-0004nX-AJ
 for bug-sed@HIDDEN; Wed, 20 Nov 2024 08:11:29 -0500
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-4315baa51d8so48918115e9.0
 for <bug-sed@HIDDEN>; Wed, 20 Nov 2024 05:11:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=suse.com; s=google; t=1732108284; x=1732713084; darn=gnu.org;
 h=mime-version:user-agent:content-transfer-encoding:date:to:from
 :subject:message-id:from:to:cc:subject:date:message-id:reply-to;
 bh=rtTKO+kmuVp/umAHCJ+Wq5nIPDR+E1ojrL9BzYSZj9c=;
 b=VU6Ewr0tm7u60DXhrFjEkCSymSyJGtGTE3PfQ3jfYUmeBO28RYFOLf2uwul9TNJ1Pm
 Fede+UMWSpx0VViBGZH9qRsD9en4h+fWusD8YT8rRYvRsQjxISSX9LNiB2ZTyI2wnLaP
 vjAe51iZCVbgB3gQTLi7HUGibKSje9aE/f/p9B4Img5rsyoCvekv/A4BXx7rWlrK04Pu
 5VIBDyfb8Wn5u7eUjVBcv8k7ALVz13FU/JEutDhCCpE2CyvsOxI42UiRTCTY1qgIqUJc
 ysHQnqytObgMg1dsERWEHYgAmiTVyoog6nsJVVRcumt3whi5DrG8luNecCCoyHzT2HsQ
 XnyA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1732108284; x=1732713084;
 h=mime-version:user-agent:content-transfer-encoding:date:to:from
 :subject:message-id:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=rtTKO+kmuVp/umAHCJ+Wq5nIPDR+E1ojrL9BzYSZj9c=;
 b=ZGOcfpyGcT/P8jd5vuCuwHBVtllBRpJ6LmojUGeDK36xAI2tTM409/l6BQNF4W/f1U
 du8/mL27yOSKCuaK9jAlf8b1muKHomCWBcExUxW+R0EdV6GUKcMPNy6AmZrBORr2NTAt
 WK7FyNQik/1dC3v/Bx9fl8kzN9dIbOxtIoNE5j93dpqiUlsIBqEqHuFU4nXvhXtDL462
 2a+4yAEcGIoEue55pGnLbW175VNQWRvoYZvu5wAHfxfWNoPY9GP5EuOKt3OJc1w8bdKJ
 uOSoYa3IbdexyXnWdDPAR48Bdl+IhCzsP+s5cUeaArlFNCrvX8jUza13lgIkcmliagcJ
 kJtA==
X-Gm-Message-State: AOJu0Yx+pHDPKCWCKRDW3X+USmj7U97IkvK29N1F2AoUPh7vYkTvlu1Z
 p4+EkZKddQNjv7v5RnbXU3vmu59M6QwNHe8avmccljyiBAIi7Ufv5KlyztzDOVZespeGkQ7vmPN
 P
X-Google-Smtp-Source: AGHT+IECAzMfAu2ZnINN9zcrpLRIgDXo1nVtkPmIbBBrexrm3jkv50eXvsDt1LvFT9a7ghWMIGNdSg==
X-Received: by 2002:a05:600c:4f0f:b0:42c:b9c7:f54b with SMTP id
 5b1f17b1804b1-433489d36ffmr26685165e9.16.1732108284659; 
 Wed, 20 Nov 2024 05:11:24 -0800 (PST)
Received: from [192.168.0.102] (static-231-80-224-77.ipcom.comunitel.net.
 [77.224.80.231]) by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-433b45d3fa6sm18761575e9.20.2024.11.20.05.11.24
 for <bug-sed@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 20 Nov 2024 05:11:24 -0800 (PST)
Message-ID: <8c0bae2897ba7968cfdfa99791144820e96a9c66.camel@HIDDEN>
Subject: sed -i --follow-symlinks fails in i586 with large paths
From: daniel.garcia@HIDDEN
To: bug-sed@HIDDEN
Date: Wed, 20 Nov 2024 14:11:23 +0100
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
User-Agent: Evolution 3.54.1 
MIME-Version: 1.0
Received-SPF: pass client-ip=2a00:1450:4864:20::32f;
 envelope-from=daniel.garcia@HIDDEN; helo=mail-wm1-x32f.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, 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-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 20 Nov 2024 23:24:20 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

I've detected that sed fails when trying to replace in place, following
symlinks in 32 bits architecture.

Steps to reproduce:

 * create a long random path with a file and a relative link:
   mkdir -p /tmp/sed/aaaa[...]
   touch /tmp/sed/aaaa[...]/f1
   ln -s f1 f2
   mv f2 /tmp/sed/aaaa[...]/

Then sed fails when trying to replace:

$ sed -i --follow-symlinks 's/a/a/' /tmp/sed/aaaa[...]/f2=20
sed: cannot rename /tmp/sed/aaaa[...]/sed5hPvOi: Not a directory

I've tested this with a full path of 100 chars.

Debugging the code I can see that the problem should be in the
"utils.c:follow_symlink" function, but I was unable to find the exact
reason and a fix.

It should be related to the "if (buf_size <=3D newlen)" because when it
fails, this is false, "linklen =3D=3D 0" and the "newlen" value is the leng=
th
of the dirname, so it returns the "dirname" of the target link file.




Acknowledgement sent to daniel.garcia@HIDDEN:
New bug report received and forwarded. Copy sent to bug-sed@HIDDEN. Full text available.
Report forwarded to bug-sed@HIDDEN:
bug#74452; Package sed. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.