GNU bug report logs - #66375
30.0.50; (error "Maximum buffer size exceeded") from (insert-file-contents "/dev/null")

Previous Next

Package: emacs;

Reported by: sds <at> gnu.org

Date: Fri, 6 Oct 2023 17:13:02 UTC

Severity: normal

Found in version 30.0.50

Full log


Message #14 received at 66375 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: sds <at> gnu.org, 66375 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: 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
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: sds <at> gnu.org,  Paul Eggert <eggert <at> cs.ucla.edu>,  66375 <at> 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.




This bug report was last modified 1 year and 247 days ago.

Previous Next


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