pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/lang/perl5 lang/perl5: Fix file descriptor leak in in-...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ac32a07c1d97
branches:  trunk
changeset: 385304:ac32a07c1d97
user:      gson <gson%pkgsrc.org@localhost>
date:      Wed Sep 19 13:52:33 2018 +0000

description:
lang/perl5: Fix file descriptor leak in in-place editing

Back-port perl commit 3d5e9c119db6b727684fe75dfcfe5831c4351bec to
fix a file descriptor leak in in-place editing which is breaking
the build of xentools48.  Should fix PR 53578.  Bump PKGREVISION.

diffstat:

 lang/perl5/Makefile             |   3 +-
 lang/perl5/distinfo             |   3 +-
 lang/perl5/patches/patch-doio.c |  96 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 2 deletions(-)

diffs (131 lines):

diff -r 1f452af714bb -r ac32a07c1d97 lang/perl5/Makefile
--- a/lang/perl5/Makefile       Wed Sep 19 13:23:36 2018 +0000
+++ b/lang/perl5/Makefile       Wed Sep 19 13:52:33 2018 +0000
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.247 2018/08/22 08:37:46 wiz Exp $
+# $NetBSD: Makefile,v 1.248 2018/09/19 13:52:33 gson Exp $
 
 .include "license.mk"
 .include "Makefile.common"
 
+PKGREVISION=   1
 COMMENT=       Practical Extraction and Report Language
 
 CONFLICTS+=    perl-base-[0-9]* perl-thread-[0-9]*
diff -r 1f452af714bb -r ac32a07c1d97 lang/perl5/distinfo
--- a/lang/perl5/distinfo       Wed Sep 19 13:23:36 2018 +0000
+++ b/lang/perl5/distinfo       Wed Sep 19 13:52:33 2018 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.152 2018/09/01 08:03:02 schmonz Exp $
+$NetBSD: distinfo,v 1.153 2018/09/19 13:52:33 gson Exp $
 
 SHA1 (perl-5.28.0.tar.xz) = c0e9e7a0dea97ec9816687d865fd461a99ef185c
 RMD160 (perl-5.28.0.tar.xz) = 34c9ad0560a2eed134e09282696bfae307cbeb6a
@@ -12,6 +12,7 @@
 SHA1 (patch-caretx.c) = 9f53a9133f8dd2f962b448d7288b5b20454c86fb
 SHA1 (patch-cflags.SH) = 7ad64e5a17b876bff4bbe238abc4a57354acf4fe
 SHA1 (patch-dist_Storable_Makefile.PL) = fd8964cf3c94ba811caaf71be21650b29e4c8e50
+SHA1 (patch-doio.c) = 684563a5416604a61632bd9cf70f4f225cce81e5
 SHA1 (patch-hints_cygwin.sh) = 1b21d927d6b7379754c4cd64a2b05d3632c35470
 SHA1 (patch-hints_netbsd.sh) = 0d549a48800372d75fe34b783529a78cba90f646
 SHA1 (patch-hints_solaris__2.sh) = 0e54889648a6f0f2a0232c5e01bef89d245c213d
diff -r 1f452af714bb -r ac32a07c1d97 lang/perl5/patches/patch-doio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/perl5/patches/patch-doio.c   Wed Sep 19 13:52:33 2018 +0000
@@ -0,0 +1,96 @@
+$NetBSD: patch-doio.c,v 1.1 2018/09/19 13:52:33 gson Exp $
+
+This is to fix PR 53578.
+
+commit 3d5e9c119db6b727684fe75dfcfe5831c4351bec
+Author: Tony Cook <tony%develop-help.com@localhost>
+Date:   Mon Jul 2 10:43:19 2018 +1000
+
+    (perl #133314) always close the directory handle on clean up
+    
+    Previously the directory handle was only closed if the rest of the
+    magic free clean up is done, but in most success cases that code
+    doesn't run, leaking the directory handle.
+    
+    So always close the directory if our AV is available.
+
+diff --git a/doio.c b/doio.c
+index 4b8923f77c..16daf9fd11 100644
+--- a/doio.c
++++ doio.c
+@@ -1163,44 +1163,50 @@ S_argvout_free(pTHX_ SV *io, MAGIC *mg) {
+ 
+     /* mg_obj can be NULL if a thread is created with the handle open, in which
+      case we leave any clean up to the parent thread */
+-    if (mg->mg_obj && IoIFP(io)) {
+-        SV **pid_psv;
++    if (mg->mg_obj) {
+ #ifdef ARGV_USE_ATFUNCTIONS
+         SV **dir_psv;
+         DIR *dir;
++
++        dir_psv = av_fetch((AV*)mg->mg_obj, ARGVMG_ORIG_DIRP, FALSE);
++        assert(dir_psv && *dir_psv && SvIOK(*dir_psv));
++        dir = INT2PTR(DIR *, SvIV(*dir_psv));
+ #endif
+-        PerlIO *iop = IoIFP(io);
++        if (IoIFP(io)) {
++            SV **pid_psv;
++            PerlIO *iop = IoIFP(io);
+ 
+-        assert(SvTYPE(mg->mg_obj) == SVt_PVAV);
++            assert(SvTYPE(mg->mg_obj) == SVt_PVAV);
+ 
+-        pid_psv = av_fetch((AV*)mg->mg_obj, ARGVMG_ORIG_PID, FALSE);
++            pid_psv = av_fetch((AV*)mg->mg_obj, ARGVMG_ORIG_PID, FALSE);
+ 
+-        assert(pid_psv && *pid_psv);
++            assert(pid_psv && *pid_psv);
+ 
+-        if (SvIV(*pid_psv) == (IV)PerlProc_getpid()) {
+-            /* if we get here the file hasn't been closed explicitly by the
+-               user and hadn't been closed implicitly by nextargv(), so
+-               abandon the edit */
+-            SV **temp_psv = av_fetch((AV*)mg->mg_obj, ARGVMG_TEMP_NAME, FALSE);
+-            const char *temp_pv = SvPVX(*temp_psv);
++            if (SvIV(*pid_psv) == (IV)PerlProc_getpid()) {
++                /* if we get here the file hasn't been closed explicitly by the
++                   user and hadn't been closed implicitly by nextargv(), so
++                   abandon the edit */
++                SV **temp_psv = av_fetch((AV*)mg->mg_obj, ARGVMG_TEMP_NAME, FALSE);
++                const char *temp_pv = SvPVX(*temp_psv);
+ 
+-            assert(temp_psv && *temp_psv && SvPOK(*temp_psv));
+-            (void)PerlIO_close(iop);
+-            IoIFP(io) = IoOFP(io) = NULL;
++                assert(temp_psv && *temp_psv && SvPOK(*temp_psv));
++                (void)PerlIO_close(iop);
++                IoIFP(io) = IoOFP(io) = NULL;
+ #ifdef ARGV_USE_ATFUNCTIONS
+-            dir_psv = av_fetch((AV*)mg->mg_obj, ARGVMG_ORIG_DIRP, FALSE);
+-            assert(dir_psv && *dir_psv && SvIOK(*dir_psv));
+-            dir = INT2PTR(DIR *, SvIV(*dir_psv));
+-            if (dir) {
+-                if (unlinkat(my_dirfd(dir), temp_pv, 0) < 0 &&
+-                    NotSupported(errno))
+-                    (void)UNLINK(temp_pv);
+-                closedir(dir);
+-            }
++                if (dir) {
++                    if (unlinkat(my_dirfd(dir), temp_pv, 0) < 0 &&
++                        NotSupported(errno))
++                        (void)UNLINK(temp_pv);
++                }
+ #else
+-            (void)UNLINK(temp_pv);
++                (void)UNLINK(temp_pv);
+ #endif
++            }
+         }
++#ifdef ARGV_USE_ATFUNCTIONS
++        if (dir)
++            closedir(dir);
++#endif
+     }
+ 
+     return 0;



Home | Main Index | Thread Index | Old Index