Fix an IO::Handle spurious error reported for regular file handles
This fixes a regression introduced with "Fix IO::Handle::error() to report write errors" commit.
This commit is contained in:
parent
c8ae198cc9
commit
1fd81e2c47
@ -0,0 +1,74 @@
|
|||||||
|
From 5efd3a36c094745739b964706aece5de29e0653e Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||||
|
Date: Thu, 6 Aug 2020 10:51:56 +0200
|
||||||
|
Subject: [PATCH] IO::Handle: Fix a spurious error reported for regular file
|
||||||
|
handles
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
89341f87 fix for GH #6799 introduced a regression when calling error()
|
||||||
|
on an IO::Handle object that was opened for reading a regular file:
|
||||||
|
|
||||||
|
$ perl -e 'open my $f, q{<}, q{/etc/hosts} or die; print qq{error\n} if $f->error'
|
||||||
|
error
|
||||||
|
|
||||||
|
In case of a regular file opened for reading, IoOFP() returns NULL and
|
||||||
|
PerlIO_error(NULL) reports -1. Compare to the case of a file opened
|
||||||
|
for writing when both IoIFP() and IoOFP() return non-NULL, equaled
|
||||||
|
pointer.
|
||||||
|
|
||||||
|
This patch fixes handling the case of the NULL output stream.
|
||||||
|
|
||||||
|
GH #18019
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
dist/IO/IO.xs | 4 ++--
|
||||||
|
dist/IO/t/io_xs.t | 10 +++++++++-
|
||||||
|
2 files changed, 11 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/dist/IO/IO.xs b/dist/IO/IO.xs
|
||||||
|
index 9158106416..fb009774c4 100644
|
||||||
|
--- a/dist/IO/IO.xs
|
||||||
|
+++ b/dist/IO/IO.xs
|
||||||
|
@@ -397,9 +397,9 @@ ferror(handle)
|
||||||
|
CODE:
|
||||||
|
if (in)
|
||||||
|
#ifdef PerlIO
|
||||||
|
- RETVAL = PerlIO_error(in) || (in != out && PerlIO_error(out));
|
||||||
|
+ RETVAL = PerlIO_error(in) || (out && in != out && PerlIO_error(out));
|
||||||
|
#else
|
||||||
|
- RETVAL = ferror(in) || (in != out && ferror(out));
|
||||||
|
+ RETVAL = ferror(in) || (out && in != out && ferror(out));
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
RETVAL = -1;
|
||||||
|
diff --git a/dist/IO/t/io_xs.t b/dist/IO/t/io_xs.t
|
||||||
|
index a8833b0651..4657088629 100644
|
||||||
|
--- a/dist/IO/t/io_xs.t
|
||||||
|
+++ b/dist/IO/t/io_xs.t
|
||||||
|
@@ -11,7 +11,7 @@ BEGIN {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-use Test::More tests => 8;
|
||||||
|
+use Test::More tests => 10;
|
||||||
|
use IO::File;
|
||||||
|
use IO::Seekable;
|
||||||
|
|
||||||
|
@@ -69,3 +69,11 @@ SKIP: {
|
||||||
|
ok(!$fh->error, "check clearerr removed the error");
|
||||||
|
close $fh; # silently ignore the error
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+{
|
||||||
|
+ # [GH #18019] IO::Handle->error misreported an error after successully
|
||||||
|
+ # opening a regular file for reading. It was a regression in GH #6799 fix.
|
||||||
|
+ ok(open(my $fh, '<', __FILE__), "a regular file opened for reading");
|
||||||
|
+ ok(!$fh->error, "no spurious error reported by error()");
|
||||||
|
+ close $fh;
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.25.4
|
||||||
|
|
11
perl.spec
11
perl.spec
@ -100,7 +100,7 @@ License: GPL+ or Artistic
|
|||||||
Epoch: %{perl_epoch}
|
Epoch: %{perl_epoch}
|
||||||
Version: %{perl_version}
|
Version: %{perl_version}
|
||||||
# release number must be even higher, because dual-lived modules will be broken otherwise
|
# release number must be even higher, because dual-lived modules will be broken otherwise
|
||||||
Release: 459%{?dist}
|
Release: 460%{?dist}
|
||||||
Summary: Practical Extraction and Report Language
|
Summary: Practical Extraction and Report Language
|
||||||
Url: https://www.perl.org/
|
Url: https://www.perl.org/
|
||||||
Source0: https://www.cpan.org/src/5.0/perl-%{perl_version}.tar.xz
|
Source0: https://www.cpan.org/src/5.0/perl-%{perl_version}.tar.xz
|
||||||
@ -209,6 +209,10 @@ Patch27: perl-5.33.0-perl-17844-don-t-update-SvCUR-until-after-we-ve-done
|
|||||||
# in upstream after 5.33.0
|
# in upstream after 5.33.0
|
||||||
Patch28: perl-5.33.0-XSUB.h-fix-MARK-and-items-variables-inside-BOOT-XSUB.patch
|
Patch28: perl-5.33.0-XSUB.h-fix-MARK-and-items-variables-inside-BOOT-XSUB.patch
|
||||||
|
|
||||||
|
# Fix an IO::Handle spurious error reported for regular file handles,
|
||||||
|
# GH#18019, proposed to upstream
|
||||||
|
Patch29: perl-5.33.0-IO-Handle-Fix-a-spurious-error-reported-for-regular-.patch
|
||||||
|
|
||||||
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
||||||
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
||||||
|
|
||||||
@ -4223,6 +4227,7 @@ you're not running VMS, this module does nothing.
|
|||||||
%patch26 -p1
|
%patch26 -p1
|
||||||
%patch27 -p1
|
%patch27 -p1
|
||||||
%patch28 -p1
|
%patch28 -p1
|
||||||
|
%patch29 -p1
|
||||||
%patch200 -p1
|
%patch200 -p1
|
||||||
%patch201 -p1
|
%patch201 -p1
|
||||||
|
|
||||||
@ -4258,6 +4263,7 @@ perl -x patchlevel.h \
|
|||||||
'Fedora Patch26: Prevent from an integer overflow in RenewDouble() macro' \
|
'Fedora Patch26: Prevent from an integer overflow in RenewDouble() macro' \
|
||||||
'Fedora Patch27: Fix a buffer overread in when reallocating formats (GH#17844)' \
|
'Fedora Patch27: Fix a buffer overread in when reallocating formats (GH#17844)' \
|
||||||
'Fedora Patch28: Fix a number of arguments passed to a BOOT XS subroutine (GH#17755)' \
|
'Fedora Patch28: Fix a number of arguments passed to a BOOT XS subroutine (GH#17755)' \
|
||||||
|
'Fedora Patch29: Fix an IO::Handle spurious error reported for regular file handles (GH#18019)' \
|
||||||
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
||||||
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
||||||
%{nil}
|
%{nil}
|
||||||
@ -6975,6 +6981,9 @@ popd
|
|||||||
|
|
||||||
# Old changelog entries are preserved in CVS.
|
# Old changelog entries are preserved in CVS.
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 06 2020 Petr Pisar <ppisar@redhat.com> - 4:5.32.0-460
|
||||||
|
- Fix an IO::Handle spurious error reported for regular file handles (GH#18019)
|
||||||
|
|
||||||
* Wed Aug 05 2020 Petr Pisar <ppisar@redhat.com> - 4:5.32.0-459
|
* Wed Aug 05 2020 Petr Pisar <ppisar@redhat.com> - 4:5.32.0-459
|
||||||
- Do not use a C compiler reserved identifiers
|
- Do not use a C compiler reserved identifiers
|
||||||
- Fix SvUV_nomg() macro definition
|
- Fix SvUV_nomg() macro definition
|
||||||
|
Loading…
Reference in New Issue
Block a user