Change 20117 by [EMAIL PROTECTED] on 2003/07/10 17:33:53
Subject: [PATCH] Restore SIGFPE on exec()
From: Chip Salzenberg <[EMAIL PROTECTED]>
Date: Thu, 10 Jul 2003 13:13:20 -0400
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/doio.c#224 edit
... //depot/perl/perl.c#507 edit
... //depot/perl/perl.h#523 edit
... //depot/perl/perlapi.h#98 edit
... //depot/perl/perlvars.h#55 edit
... //depot/perl/toke.c#478 edit
Differences ...
==== //depot/perl/doio.c#224 (text) ====
Index: perl/doio.c
--- perl/doio.c#223~19789~ Sun Jun 15 10:08:02 2003
+++ perl/doio.c Thu Jul 10 10:33:53 2003
@@ -1429,10 +1429,12 @@
if ((!really && *PL_Argv[0] != '/') ||
(really && *tmps != '/')) /* will execvp use PATH? */
TAINT_ENV(); /* testing IFS here is overkill, probably */
+ PERL_FPU_PRE_EXEC
if (really && *tmps)
PerlProc_execvp(tmps,EXEC_ARGV_CAST(PL_Argv));
else
PerlProc_execvp(PL_Argv[0],EXEC_ARGV_CAST(PL_Argv));
+ PERL_FPU_POST_EXEC
if (ckWARN(WARN_EXEC))
Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
(really ? tmps : PL_Argv[0]), Strerror(errno));
@@ -1502,7 +1504,9 @@
*--s = '\0';
if (s[-1] == '\'') {
*--s = '\0';
+ PERL_FPU_PRE_EXEC
PerlProc_execl(PL_cshname,"csh", flags, ncmd, (char*)0);
+ PERL_FPU_POST_EXEC
*s = '\'';
return FALSE;
}
@@ -1545,7 +1549,9 @@
}
}
doshell:
+ PERL_FPU_PRE_EXEC
PerlProc_execl(PL_sh_path, "sh", "-c", cmd, (char*)0);
+ PERL_FPU_POST_EXEC
return FALSE;
}
}
@@ -1563,7 +1569,9 @@
}
*a = Nullch;
if (PL_Argv[0]) {
+ PERL_FPU_PRE_EXEC
PerlProc_execvp(PL_Argv[0],PL_Argv);
+ PERL_FPU_POST_EXEC
if (errno == ENOEXEC) { /* for system V NIH syndrome */
do_execfree();
goto doshell;
==== //depot/perl/perl.c#507 (text) ====
Index: perl/perl.c
--- perl/perl.c#506~20062~ Mon Jul 7 11:27:02 2003
+++ perl/perl.c Thu Jul 10 10:33:53 2003
@@ -2982,10 +2982,12 @@
PL_statbuf.st_mode & (S_ISUID|S_ISGID))
{
/* try again */
+ PERL_FPU_PRE_EXEC
PerlProc_execv(Perl_form(aTHX_ "%s/sperl"PERL_FS_VER_FMT,
BIN_EXP, (int)PERL_REVISION,
(int)PERL_VERSION,
(int)PERL_SUBVERSION), PL_origargv);
+ PERL_FPU_POST_EXEC
Perl_croak(aTHX_ "Can't do setuid\n");
}
# endif
@@ -3242,9 +3244,11 @@
(void)PerlIO_close(PL_rsfp);
#ifndef IAMSUID
/* try again */
+ PERL_FPU_PRE_EXEC
PerlProc_execv(Perl_form(aTHX_ "%s/sperl"PERL_FS_VER_FMT, BIN_EXP,
(int)PERL_REVISION, (int)PERL_VERSION,
(int)PERL_SUBVERSION), PL_origargv);
+ PERL_FPU_POST_EXEC
#endif
Perl_croak(aTHX_ "Can't do setuid\n");
}
@@ -3326,9 +3330,11 @@
#if defined(HAS_FCNTL) && defined(F_SETFD)
fcntl(PerlIO_fileno(PL_rsfp),F_SETFD,0); /* ensure no close-on-exec */
#endif
+ PERL_FPU_PRE_EXEC
PerlProc_execv(Perl_form(aTHX_ "%s/perl"PERL_FS_VER_FMT, BIN_EXP,
(int)PERL_REVISION, (int)PERL_VERSION,
(int)PERL_SUBVERSION), PL_origargv);/* try again */
+ PERL_FPU_POST_EXEC
Perl_croak(aTHX_ "Can't do setuid\n");
#endif /* IAMSUID */
#else /* !DOSUID */
==== //depot/perl/perl.h#523 (text) ====
Index: perl/perl.h
--- perl/perl.h#522~19979~ Fri Jul 4 01:33:32 2003
+++ perl/perl.h Thu Jul 10 10:33:53 2003
@@ -1935,11 +1935,17 @@
# define PERL_FPU_INIT fpsetmask(0);
# else
# if defined(SIGFPE) && defined(SIG_IGN)
-# define PERL_FPU_INIT signal(SIGFPE, SIG_IGN);
+# define PERL_FPU_INIT PL_sigfpe_saved = signal(SIGFPE, SIG_IGN)
+# define PERL_FPU_PRE_EXEC { Sigsave_t xfpe; rsignal_save(SIGFPE,
PL_sigfpe_saved, &xfpe);
+# define PERL_FPU_POST_EXEC rsignal_restore(SIGFPE, &xfpe); }
# else
# define PERL_FPU_INIT
# endif
# endif
+#endif
+#ifndef PERL_FPU_PRE_EXEC
+# define PERL_FPU_PRE_EXEC {
+# define PERL_FPU_POST_EXEC }
#endif
#ifndef PERL_SYS_INIT3
==== //depot/perl/perlapi.h#98 (text+w) ====
Index: perl/perlapi.h
--- perl/perlapi.h#97~20114~ Thu Jul 10 08:06:41 2003
+++ perl/perlapi.h Thu Jul 10 10:33:53 2003
@@ -944,6 +944,8 @@
#define PL_patleave (*Perl_Gpatleave_ptr(NULL))
#undef PL_sh_path
#define PL_sh_path (*Perl_Gsh_path_ptr(NULL))
+#undef PL_sigfpe_saved
+#define PL_sigfpe_saved (*Perl_Gsigfpe_saved_ptr(NULL))
#undef PL_thr_key
#define PL_thr_key (*Perl_Gthr_key_ptr(NULL))
==== //depot/perl/perlvars.h#55 (text) ====
Index: perl/perlvars.h
--- perl/perlvars.h#54~19979~ Fri Jul 4 01:33:32 2003
+++ perl/perlvars.h Thu Jul 10 10:33:53 2003
@@ -55,3 +55,7 @@
/* This is constant on most architectures, a global on OS/2 */
PERLVARI(Gsh_path, char *, SH_PATH)/* full path of shell */
+/* If Perl has to ignore SIGPFE, this is its saved state.
+ * See perl.h macros PERL_FPU_INIT and PERL_FPU_{PRE,POST}_EXEC. */
+PERLVAR(Gsigfpe_saved, Sighandler_t)
+
==== //depot/perl/toke.c#478 (text) ====
Index: perl/toke.c
--- perl/toke.c#477~20097~ Wed Jul 9 10:27:35 2003
+++ perl/toke.c Thu Jul 10 10:33:53 2003
@@ -2704,7 +2704,9 @@
else
newargv = PL_origargv;
newargv[0] = ipath;
+ PERL_FPU_PRE_EXEC
PerlProc_execv(ipath, EXEC_ARGV_CAST(newargv));
+ PERL_FPU_POST_EXEC
Perl_croak(aTHX_ "Can't exec %s", ipath);
}
#endif
End of Patch.