GNU bug report logs - #18370
insert-file-contents: forbids also beg, end for non-regular (special) files

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: emacs; Severity: minor; Reported by: Ivan Shmakov <ivan@HIDDEN>; dated Sun, 31 Aug 2014 19:51:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at submit) by debbugs.gnu.org; 31 Aug 2014 19:50:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Aug 31 15:50:23 2014
Received: from localhost ([127.0.0.1]:55139 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1XOB8o-0006GS-Pj
	for submit <at> debbugs.gnu.org; Sun, 31 Aug 2014 15:50:23 -0400
Received: from fely.am-1.org ([78.47.74.50]:52783)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <ivan@HIDDEN>) id 1XOB8l-0006GG-Ll
 for submit <at> debbugs.gnu.org; Sun, 31 Aug 2014 15:50:21 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=siamics.net;
 s=a2013295; 
 h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Sender:Subject:To:From;
 bh=A8TI6hGnaamNfbsOOl4KSGZF3IG+BN/jxJ531Fy8rmo=; 
 b=mOmBOELefW/XfLqkfgRAOMj1rG30/LCLFm/rmJJWLlvdnoFQCjtqZMK3AMJ/slj7ZgNt6gqjmSwsLREb8zevqIIY8CR/rdaBmnKeDSBzKv8bUZyhKBikl9Hqd/C9nyMEbJtuTAba7xdx/ehjfzBomMrtvERxTrZiMZOyospVPJM=;
Received: from [2a02:2560:6d4:26ca::1:1d] (helo=violet.siamics.net)
 by fely.am-1.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
 (Exim 4.80) (envelope-from <ivan@HIDDEN>) id 1XOB8j-00038s-Pm
 for submit <at> debbugs.gnu.org; Sun, 31 Aug 2014 19:50:17 +0000
Received: from localhost ([::1] helo=violet.siamics.net)
 by violet.siamics.net with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128)
 (Exim 4.80) (envelope-from <ivan@HIDDEN>) id 1XOB8c-0001Ae-Jq
 for submit <at> debbugs.gnu.org; Mon, 01 Sep 2014 02:50:10 +0700
From: Ivan Shmakov <ivan@HIDDEN>
To: submit <at> debbugs.gnu.org
Subject: insert-file-contents: forbids also beg,
 end for non-regular (special) files 
Date: Sun, 31 Aug 2014 19:50:09 +0000
Message-ID: <87y4u4tp5a.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://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: <http://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: 0.7 (/)

Package:  emacs
Severity: minor

	As currently implemented, insert-file-contents disallows not
	only (as per (elisp.info) Reading from Files) the case of either
	=E2=80=98visit=E2=80=99 or =E2=80=98replace=E2=80=99 arguments being non-n=
il, but also when
	non-nil are either =E2=80=98beg=E2=80=99 or =E2=80=98end=E2=80=99 (or both=
):

  3506	  /* This code will need to be changed in order to work on named
  3507	     pipes, and it's probably just not worth it.  So we should at
  3508	     least signal an error.  */
  3509	  if (!S_ISREG (st.st_mode))
  3510	    {
  3511	      not_regular =3D 1;
=E2=8B=AF
  3516	      if (! NILP (replace) || ! NILP (beg) || ! NILP (end))
  3517		xsignal2 (Qfile_error,
  3518			  build_string ("not a regular file"), orig_filename);
  3519	    }

	This, however, precludes the use of insert-file-contents not
	only on named pipes, but also on /dev/cdrom, /dev/random, and
	the like, =E2=80=93 for (and especially in the case of the latter) the
	=E2=80=98end=E2=80=99 argument gets rather essential here, as otherwise the
	function is likely to read much more than the caller will be
	able to handle at any single time.

	Instead, I=E2=80=99d suggest that =E2=80=98end=E2=80=99 is always allowed,=
 and =E2=80=98beg=E2=80=99 is
	allowed when the file in question is /seekable/, =E2=80=93 which, ISTR,
	is possible to check beforehand (lseek (fd, 0, SEEK_CUR) < 0?)

	From a glance over the code, this new behavior wouldn=E2=80=99t be all
	that hard to implement (some not_regular checks will have to be
	replaced with the ones against beg_offset, end_offset, etc.),
	but from what I read, =E2=80=93 it=E2=80=99s already going to be more than=
 I can
	test right now.  So no .diff this time, alas.

--=20
FSF associate member #7257  http://boycottsystemd.org/  =E2=80=A6 3013 B6A0=
 230E 334A




Acknowledgement sent to Ivan Shmakov <ivan@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#18370; Package emacs. 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: Fri, 31 Oct 2014 17:00:04 UTC

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