From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#66375: 30.0.50; (error "Maximum buffer size exceeded") from (insert-file-contents "/dev/null") Date: Sat, 07 Oct 2023 10:43:24 +0300 Message-ID: <83a5su27z7.fsf@gnu.org> References: <87cyxru14o.fsf@gnu.org> <83o7hb0yfk.fsf@gnu.org> <87sf6naq5a.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38918"; mail-complaints-to="usenet@ciao.gmane.io" Cc: sds@gnu.org, 66375@debbugs.gnu.org, eggert@cs.ucla.edu To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 07 09:43:58 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qp1yg-0009ut-DS for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Oct 2023 09:43:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qp1yT-0004Zj-MH; Sat, 07 Oct 2023 03:43:45 -0400 Original-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 ) id 1qp1yR-0004ZK-Lu for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 03:43:43 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qp1yR-0007IN-EF for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 03:43:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qp1yk-0003UM-Bu for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 03:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Oct 2023 07:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66375 X-GNU-PR-Package: emacs Original-Received: via spool by 66375-submit@debbugs.gnu.org id=B66375.169666462113369 (code B ref 66375); Sat, 07 Oct 2023 07:44:02 +0000 Original-Received: (at 66375) by debbugs.gnu.org; 7 Oct 2023 07:43:41 +0000 Original-Received: from localhost ([127.0.0.1]:53271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp1yP-0003TZ-8M for submit@debbugs.gnu.org; Sat, 07 Oct 2023 03:43:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp1yN-0003TK-DG for 66375@debbugs.gnu.org; Sat, 07 Oct 2023 03:43:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qp1xy-0007ER-8B; Sat, 07 Oct 2023 03:43:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=67EN/LHPk581vApPG1ocAnaWbeoyGnWEvNXx6AAlTR8=; b=YesYKTK8C8khMXfL67xt QERI6wD902fydC7XSy/u91T2Pp6oWPOHgXsuTsYIdhvJt+XhaK40TF2ECb+5BWF7Ss3EZBDu7Ix+/ 5Q4G+0+Jom5OtJr9vkFkGVaotPOKSzem0xBhxMeIz1h1F6Dq3i7vQQ4Kfj0VZrKMz6ZeyLGLotXkc 6CEk5E1GPNYvCuKkfiPe1oJ5W2eCx3OW5og+1GIpO2iFnvzKNEgFDl/Dx5vfw7uoXvYZxHLU4WeAe gkCIBoTq874HDjjA2Pfh2yuw9ivbj3jzdbDW90/mT3+8DbFF+FXx2kGcOFwQnomWYi3QiWGTW2gxX cAYQnjZHXC7guw==; In-Reply-To: <87sf6naq5a.fsf@yahoo.com> (message from Po Lu on Sat, 07 Oct 2023 14:43:45 +0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271980 Archived-At: > From: Po Lu > Cc: sds@gnu.org, Paul Eggert , 66375@debbugs.gnu.org > Date: Sat, 07 Oct 2023 14:43:45 +0800 > > --- a/src/fileio.c > +++ b/src/fileio.c > @@ -4746,7 +4746,7 @@ DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, > goto handled; > } > > - if (seekable || !NILP (end)) > + if (((regular || !NILP (end)) && seekable) || !NILP (end)) > total = end_offset - beg_offset; > else > /* For a special file, all we can do is guess. */ > This does a couple of redundant tests: . regular non-zero means seekable must be non-zero . NILP (end) is tested twice for now good reason I think the above should be cleaned up to better understand the logic. More generally, I think 'total' should not be computed in this naïve way when end_offset is -1, i.e. unless end_offset is either the result of fstat/stat or the result of actually seeking to the end of file/device.