File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 45
45
# include <sys/sysmacros.h>
46
46
#endif
47
47
48
+ #if (defined(__sun ) && !defined(_LP64 )) || defined(_AIX )
49
+ #define POSIX_PID_MAX LONG_MAX
50
+ #else
51
+ #define POSIX_PID_MAX INT_MAX
52
+ #endif
53
+
48
54
#include "posix_arginfo.h"
49
55
50
56
ZEND_DECLARE_MODULE_GLOBALS (posix )
@@ -129,6 +135,11 @@ PHP_FUNCTION(posix_kill)
129
135
Z_PARAM_LONG (sig )
130
136
ZEND_PARSE_PARAMETERS_END ();
131
137
138
+ if (pid < -1 || pid > POSIX_PID_MAX ) {
139
+ zend_argument_value_error (1 , "must be between -1 and " ZEND_LONG_FMT , POSIX_PID_MAX );
140
+ RETURN_THROWS ();
141
+ }
142
+
132
143
if (kill (pid , sig ) < 0 ) {
133
144
POSIX_G (last_error ) = errno ;
134
145
RETURN_FALSE ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ posix_kill() with large pid
3
+ --EXTENSIONS--
4
+ posix
5
+ --FILE--
6
+ <?php
7
+ // with pid overflow, it ends up being -1 which means all permissible processes are affected
8
+ try {
9
+ posix_kill (PHP_INT_MAX , SIGTERM );
10
+ } catch (\ValueError $ e ) {
11
+ echo $ e ->getMessage (), PHP_EOL ;
12
+ }
13
+
14
+ try {
15
+ posix_kill (PHP_INT_MIN , SIGTERM );
16
+ } catch (\ValueError $ e ) {
17
+ echo $ e ->getMessage (), PHP_EOL ;
18
+ }
19
+ ?>
20
+ --EXPECTF--
21
+ posix_kill(): Argument #1 ($process_id) must be between -1 and %d
22
+ posix_kill(): Argument #1 ($process_id) must be between -1 and %d
You can’t perform that action at this time.
0 commit comments