Do not mangle errno from failed socket call
This commit is contained in:
		
							parent
							
								
									7f1876649d
								
							
						
					
					
						commit
						cfbeeaff35
					
				| @ -0,0 +1,73 @@ | ||||
| From 3f6b66c14467c0f8c7459e32c576618155ca89f3 Mon Sep 17 00:00:00 2001 | ||||
| From: Tony Cook <tony@develop-help.com> | ||||
| Date: Thu, 16 Jun 2016 14:08:18 +1000 | ||||
| Subject: [PATCH] (perl #128316) preserve errno from failed system calls | ||||
| MIME-Version: 1.0 | ||||
| Content-Type: text/plain; charset=UTF-8 | ||||
| Content-Transfer-Encoding: 8bit | ||||
| 
 | ||||
| Signed-off-by: Petr Písař <ppisar@redhat.com> | ||||
| ---
 | ||||
|  pp_sys.c      |  4 ++-- | ||||
|  t/io/socket.t | 22 ++++++++++++++++++++++ | ||||
|  2 files changed, 24 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| diff --git a/pp_sys.c b/pp_sys.c
 | ||||
| index 33cba46..3bf2673 100644
 | ||||
| --- a/pp_sys.c
 | ||||
| +++ b/pp_sys.c
 | ||||
| @@ -2497,7 +2497,6 @@ PP(pp_socket)
 | ||||
|      TAINT_PROPER("socket"); | ||||
|      fd = PerlSock_socket(domain, type, protocol); | ||||
|      if (fd < 0) { | ||||
| -        SETERRNO(EBADF,RMS_IFI);
 | ||||
|  	RETPUSHUNDEF; | ||||
|      } | ||||
|      IoIFP(io) = PerlIO_fdopen(fd, "r"SOCKET_OPEN_MODE);	/* stdio gets confused about sockets */ | ||||
| @@ -3531,8 +3530,9 @@ PP(pp_fttext)
 | ||||
|          } | ||||
|  	PL_laststatval = PerlLIO_fstat(fd, &PL_statcache); | ||||
|  	if (PL_laststatval < 0)	{ | ||||
| +            dSAVE_ERRNO;
 | ||||
|  	    (void)PerlIO_close(fp); | ||||
| -            SETERRNO(EBADF,RMS_IFI);
 | ||||
| +            RESTORE_ERRNO;
 | ||||
|  	    FT_RETURNUNDEF; | ||||
|  	} | ||||
|  	PerlIO_binmode(aTHX_ fp, '<', O_BINARY, NULL); | ||||
| diff --git a/t/io/socket.t b/t/io/socket.t
 | ||||
| index b51079a..54e4438 100644
 | ||||
| --- a/t/io/socket.t
 | ||||
| +++ b/t/io/socket.t
 | ||||
| @@ -128,6 +128,28 @@ SKIP: {
 | ||||
|      } | ||||
|  } | ||||
|   | ||||
| +SKIP:
 | ||||
| +{
 | ||||
| +    eval { require Errno; defined &Errno::EMFILE }
 | ||||
| +      or skip "Can't load Errno or EMFILE not defined", 1;
 | ||||
| +    my @socks;
 | ||||
| +    my $sock_limit = 1000; # don't consume every file in the system
 | ||||
| +    # Default limits on various systems I have:
 | ||||
| +    #  65536 - Linux
 | ||||
| +    #    256 - Solaris
 | ||||
| +    #    128 - NetBSD
 | ||||
| +    #    256 - Cygwin
 | ||||
| +    #    256 - darwin
 | ||||
| +    while (@socks < $sock_limit) {
 | ||||
| +        socket my $work, PF_INET, SOCK_STREAM, $tcp
 | ||||
| +          or last;
 | ||||
| +        push @socks, $work;
 | ||||
| +    }
 | ||||
| +    @socks == $sock_limit
 | ||||
| +      and skip "Didn't run out of open handles", 1;
 | ||||
| +    is(0+$!, Errno::EMFILE(), "check correct errno for too many files");
 | ||||
| +}
 | ||||
| +
 | ||||
|  done_testing(); | ||||
|   | ||||
|  my @child_tests; | ||||
| -- 
 | ||||
| 2.5.5 | ||||
| 
 | ||||
							
								
								
									
										11
									
								
								perl.spec
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								perl.spec
									
									
									
									
									
								
							| @ -28,7 +28,7 @@ | ||||
| Name:           perl | ||||
| Version:        %{perl_version} | ||||
| # release number must be even higher, because dual-lived modules will be broken otherwise | ||||
| Release:        365%{?dist} | ||||
| Release:        366%{?dist} | ||||
| Epoch:          %{perl_epoch} | ||||
| Summary:        Practical Extraction and Report Language | ||||
| Group:          Development/Languages | ||||
| @ -117,6 +117,10 @@ Patch30:        perl-5.22.1-Replace-EU-MM-dependnecy-with-EU-MM-Utils-in-IPC-Cmd | ||||
| # RT#128313, in upstream after 5.25.1 | ||||
| Patch31:        perl-5.24.0-Fix-a-memory-leak-in-strict-regex-posix-classes.patch | ||||
| 
 | ||||
| # Do not mangle errno from failed socket calls, RT#128316, | ||||
| # in upstream after 5.25.1 | ||||
| Patch32:        perl-5.25.1-perl-128316-preserve-errno-from-failed-system-calls.patch | ||||
| 
 | ||||
| # 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 | ||||
| 
 | ||||
| @ -2767,6 +2771,7 @@ Perl extension for Version Objects | ||||
| %patch28 -p1 | ||||
| %patch30 -p1 | ||||
| %patch31 -p1 | ||||
| %patch32 -p1 | ||||
| %patch200 -p1 | ||||
| %patch201 -p1 | ||||
| 
 | ||||
| @ -2789,6 +2794,7 @@ perl -x patchlevel.h \ | ||||
|     'Fedora Patch28: Make magic vtable writable as a work-around for Coro (CPAN RT#101063)' \ | ||||
|     'Fedora Patch30: Replace EU::MakeMaker dependency with EU::MM::Utils in IPC::Cmd (bug #1129443)' \ | ||||
|     'Fedora Patch31: Fix a memory leak in compiling a POSIX class (RT#128313)' \ | ||||
|     'Fedora Patch32: Do not mangle errno from failed socket calls (RT#128316)' \ | ||||
|     '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' \ | ||||
|     %{nil} | ||||
| @ -5055,6 +5061,9 @@ popd | ||||
| 
 | ||||
| # Old changelog entries are preserved in CVS. | ||||
| %changelog | ||||
| * Thu Jun 16 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-366 | ||||
| - Do not mangle errno from failed socket calls (RT#128316) | ||||
| 
 | ||||
| * Tue Jun 14 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-365 | ||||
| - Fix a memory leak when compiling a regular expression with a POSIX class | ||||
|   (RT#128313) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user