Change 29996 by [EMAIL PROTECTED] on 2007/01/26 09:54:13
Integrate:
[ 28376]
Subject: [PATCH] Add error checks after execing PL_cshname or PL_sh_path
From: "Jan Dubois" <[EMAIL PROTECTED]>
Date: Wed, 7 Jun 2006 15:53:02 -0700
Message-ID: <[EMAIL PROTECTED]>
[ 28377]
Mark the 1st argument to S_exec_failed as non null
[ 28404]
Subject: [perl #39365] Bug in toke.c (eval in subst)
From: [EMAIL PROTECTED] (via RT) <[EMAIL PROTECTED]>
Date: Fri, 09 Jun 2006 02:08:44 -0700
Message-ID: <[EMAIL PROTECTED]>
plus a regression test.
[ 28409]
Change 28404 broke the construct s/foo/<<BAR/e. So, try to be more
clever. If the right hand side of s///e contains a #, then maybe
it's a comment, so add a \n after it. Obviously, this is fast, but
won't cover all possible cases.
Affected files ...
... //depot/maint-5.8/perl/doio.c#96 integrate
... //depot/maint-5.8/perl/embed.fnc#194 integrate
... //depot/maint-5.8/perl/embed.h#146 integrate
... //depot/maint-5.8/perl/proto.h#184 integrate
... //depot/maint-5.8/perl/t/comp/parser.t#17 integrate
... //depot/maint-5.8/perl/toke.c#151 integrate
Differences ...
==== //depot/maint-5.8/perl/doio.c#96 (text) ====
Index: perl/doio.c
--- perl/doio.c#95~29993~ 2007-01-26 01:15:17.000000000 -0800
+++ perl/doio.c 2007-01-26 01:54:13.000000000 -0800
@@ -1392,6 +1392,19 @@
return PL_laststatval;
}
+static void
+S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
+{
+ const int e = errno;
+ if (ckWARN(WARN_EXEC))
+ Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
+ cmd, Strerror(e));
+ if (do_report) {
+ PerlLIO_write(fd, (void*)&e, sizeof(int));
+ PerlLIO_close(fd);
+ }
+}
+
bool
Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,
int fd, int do_report)
@@ -1423,15 +1436,7 @@
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));
- if (do_report) {
- const int e = errno;
-
- PerlLIO_write(fd, (void*)&e, sizeof(int));
- PerlLIO_close(fd);
- }
+ S_exec_failed(aTHX_ (really ? tmps : PL_Argv[0]), fd, do_report);
}
do_execfree();
#endif
@@ -1500,6 +1505,7 @@
PerlProc_execl(PL_cshname, "csh", flags, ncmd, NULL);
PERL_FPU_POST_EXEC
*s = '\'';
+ S_exec_failed(aTHX_ PL_cshname, fd, do_report);
Safefree(cmd);
return FALSE;
}
@@ -1547,6 +1553,7 @@
PERL_FPU_PRE_EXEC
PerlProc_execl(PL_sh_path, "sh", "-c", cmd, NULL);
PERL_FPU_POST_EXEC
+ S_exec_failed(aTHX_ PL_sh_path, fd, do_report);
Safefree(cmd);
return FALSE;
}
@@ -1574,14 +1581,7 @@
do_execfree();
goto doshell;
}
- if (ckWARN(WARN_EXEC))
- Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
- PL_Argv[0], Strerror(errno));
- if (do_report) {
- const int e = errno;
- PerlLIO_write(fd, (const void*)&e, sizeof(int));
- PerlLIO_close(fd);
- }
+ S_exec_failed(aTHX_ PL_Argv[0], fd, do_report);
}
do_execfree();
Safefree(cmd);
==== //depot/maint-5.8/perl/embed.fnc#194 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#193~29993~ 2007-01-26 01:15:17.000000000 -0800
+++ perl/embed.fnc 2007-01-26 01:54:13.000000000 -0800
@@ -215,6 +215,9 @@
p |bool |do_exec3 |NN char* cmd|int fd|int do_report
#endif
p |void |do_execfree
+#ifdef PERL_IN_DOIO_C
+s |void |exec_failed |NN const char *cmd|int fd|int do_report
+#endif
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
p |I32 |do_ipcctl |I32 optype|NN SV** mark|NN SV** sp
p |I32 |do_ipcget |I32 optype|NN SV** mark|NN SV** sp
==== //depot/maint-5.8/perl/embed.h#146 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#145~29993~ 2007-01-26 01:15:17.000000000 -0800
+++ perl/embed.h 2007-01-26 01:54:13.000000000 -0800
@@ -198,6 +198,11 @@
#ifdef PERL_CORE
#define do_execfree Perl_do_execfree
#endif
+#ifdef PERL_IN_DOIO_C
+#ifdef PERL_CORE
+#define exec_failed S_exec_failed
+#endif
+#endif
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
#ifdef PERL_CORE
#define do_ipcctl Perl_do_ipcctl
@@ -2287,6 +2292,11 @@
#ifdef PERL_CORE
#define do_execfree() Perl_do_execfree(aTHX)
#endif
+#ifdef PERL_IN_DOIO_C
+#ifdef PERL_CORE
+#define exec_failed(a,b,c) S_exec_failed(aTHX_ a,b,c)
+#endif
+#endif
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
#ifdef PERL_CORE
#define do_ipcctl(a,b,c) Perl_do_ipcctl(aTHX_ a,b,c)
==== //depot/maint-5.8/perl/proto.h#184 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#183~29993~ 2007-01-26 01:15:17.000000000 -0800
+++ perl/proto.h 2007-01-26 01:54:13.000000000 -0800
@@ -287,6 +287,11 @@
PERL_CALLCONV bool Perl_do_exec3(pTHX_ char* cmd, int fd, int do_report);
#endif
PERL_CALLCONV void Perl_do_execfree(pTHX);
+#ifdef PERL_IN_DOIO_C
+STATIC void S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
+ __attribute__nonnull__(pTHX_1);
+
+#endif
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
PERL_CALLCONV I32 Perl_do_ipcctl(pTHX_ I32 optype, SV** mark, SV** sp);
PERL_CALLCONV I32 Perl_do_ipcget(pTHX_ I32 optype, SV** mark, SV** sp);
==== //depot/maint-5.8/perl/t/comp/parser.t#17 (text) ====
Index: perl/t/comp/parser.t
--- perl/t/comp/parser.t#16~29733~ 2007-01-09 03:12:58.000000000 -0800
+++ perl/t/comp/parser.t 2007-01-26 01:54:13.000000000 -0800
@@ -9,7 +9,7 @@
}
require "./test.pl";
-plan( tests => 55 );
+plan( tests => 56 );
eval '[EMAIL PROTECTED];';
like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '[EMAIL
PROTECTED]' );
@@ -191,3 +191,6 @@
like($@, qr/That use of \$\[ is unsupported/,
'cannot assign list of <1 elements to $[');
}
+
+eval q{ s/x/#/e };
+is( $@, '', 'comments in s///e' );
==== //depot/maint-5.8/perl/toke.c#151 (text) ====
Index: perl/toke.c
--- perl/toke.c#150~29993~ 2007-01-26 01:15:17.000000000 -0800
+++ perl/toke.c 2007-01-26 01:54:13.000000000 -0800
@@ -9499,6 +9499,8 @@
sv_catpv(repl, es ? "eval " : "do ");
sv_catpvs(repl, "{");
sv_catsv(repl, PL_lex_repl);
+ if (strchr(SvPVX(PL_lex_repl), '#'))
+ sv_catpvs(repl, "\n");
sv_catpvs(repl, "}");
SvEVALED_on(repl);
SvREFCNT_dec(PL_lex_repl);
End of Patch.