GNU bug report logs -
#18370
insert-file-contents: forbids also beg, end for non-regular (special) files
Previous Next
Reported by: Ivan Shmakov <ivan <at> siamics.net>
Date: Sun, 31 Aug 2014 19:51:01 UTC
Severity: minor
Tags: moreinfo
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18370 in the body.
You can then email your comments to 18370 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18370
; Package
emacs
.
(Sun, 31 Aug 2014 19:51:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ivan Shmakov <ivan <at> siamics.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 31 Aug 2014 19:51:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Package: emacs
Severity: minor
As currently implemented, insert-file-contents disallows not
only (as per (elisp.info) Reading from Files) the case of either
‘visit’ or ‘replace’ arguments being non-nil, but also when
non-nil are either ‘beg’ or ‘end’ (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 = 1;
⋯
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, – for (and especially in the case of the latter) the
‘end’ 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’d suggest that ‘end’ is always allowed, and ‘beg’ is
allowed when the file in question is /seekable/, – which, ISTR,
is possible to check beforehand (lseek (fd, 0, SEEK_CUR) < 0?)
From a glance over the code, this new behavior wouldn’t 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, – it’s already going to be more than I can
test right now. So no .diff this time, alas.
--
FSF associate member #7257 http://boycottsystemd.org/ … 3013 B6A0 230E 334A
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18370
; Package
emacs
.
(Wed, 11 May 2022 15:24:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 18370 <at> debbugs.gnu.org (full text, mbox):
Ivan Shmakov <ivan <at> siamics.net> writes:
> As currently implemented, insert-file-contents disallows not
> only (as per (elisp.info) Reading from Files) the case of either
> ‘visit’ or ‘replace’ arguments being non-nil, but also when
> non-nil are either ‘beg’ or ‘end’ (or both):
[...]
> This, however, precludes the use of insert-file-contents not
> only on named pipes, but also on /dev/cdrom, /dev/random, and
> the like, – for (and especially in the case of the latter) the
> ‘end’ 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’d suggest that ‘end’ is always allowed, and ‘beg’ is
> allowed when the file in question is /seekable/, – which, ISTR,
> is possible to check beforehand (lseek (fd, 0, SEEK_CUR) < 0?)
>
> From a glance over the code, this new behavior wouldn’t 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, – it’s already going to be more than I can
> test right now. So no .diff this time, alas.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
Simple test case:
(insert-file-contents "/dev/urandom" nil nil 10)
This still fails in Emacs 29, and it would indeed be nice if it worked.
I seem to remember this being discussed previously, and that... er...
no, I can't really recall anything more than that.
Does anybody see any good reasons why we shouldn't allow this? If not,
I can take a stab at implementing it...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 11 May 2022 15:24:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18370
; Package
emacs
.
(Sat, 11 Jun 2022 12:41:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 18370 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Simple test case:
>
> (insert-file-contents "/dev/urandom" nil nil 10)
>
> This still fails in Emacs 29, and it would indeed be nice if it worked.
> I seem to remember this being discussed previously, and that... er...
> no, I can't really recall anything more than that.
>
> Does anybody see any good reasons why we shouldn't allow this? If not,
> I can take a stab at implementing it...
There were no objections, so I've now added this to Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
18370 <at> debbugs.gnu.org and Ivan Shmakov <ivan <at> siamics.net>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 11 Jun 2022 12:41:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18370
; Package
emacs
.
(Sun, 12 Jun 2022 07:51:01 GMT)
Full text and
rfc822 format available.
Message #18 received at 18370 <at> debbugs.gnu.org (full text, mbox):
>> Simple test case:
>>
>> (insert-file-contents "/dev/urandom" nil nil 10)
>>
>> This still fails in Emacs 29, and it would indeed be nice if it worked.
>> I seem to remember this being discussed previously, and that... er...
>> no, I can't really recall anything more than that.
>>
>> Does anybody see any good reasons why we shouldn't allow this? If not,
>> I can take a stab at implementing it...
>
> There were no objections, so I've now added this to Emacs 29.
Maybe this is related to bug#9800, still unfixed after this change.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#18370
; Package
emacs
.
(Sun, 12 Jun 2022 10:20:01 GMT)
Full text and
rfc822 format available.
Message #21 received at 18370 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
> Maybe this is related to bug#9800, still unfixed after this change.
I think it's somewhat unrelated -- the /proc files are "regular" files,
they just tend to "grow" while reading. I think the solution sketched
in that bug report sounds OK.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 10 Jul 2022 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 4 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.