croak in POSIX::sigaction() when passed a negative signal instead
Steve Peters [Thu, 9 Mar 2006 16:03:21 +0000 (16:03 +0000)]
dumping core.

p4raw-id: //depot/perl@27440

ext/POSIX/POSIX.xs
ext/POSIX/t/sigaction.t

index 730e7e0..50f3a74 100644 (file)
@@ -1260,6 +1260,10 @@ sigaction(sig, optaction, oldaction = 0)
            SV** svp;
            SV** sigsvp;
 
+            if (sig < 0) {
+                croak("Negative signals are not allowed");
+            }
+
            if (sig == 0 && SvPOK(ST(0))) {
                const char *s = SvPVX_const(ST(0));
                int i = whichsig(s);
index 813960a..c33b732 100644 (file)
@@ -205,3 +205,6 @@ SKIP: {
     kill 'HUP', $$;
 }
 
+eval { sigaction(-999, "foo"); };
+like($@, qr/Negative signals/,
+    "Prevent negative signals instead of core dumping");