This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace PHP\Wrappers; |
||
4 | |||
5 | /** |
||
6 | * Class Sockets |
||
7 | * |
||
8 | * @package PHP\Wrappers |
||
9 | * @author Aurimas Niekis <[email protected]> |
||
10 | */ |
||
11 | class Sockets |
||
12 | { |
||
13 | /** |
||
14 | * Accepts a connection on a socket |
||
15 | * |
||
16 | * @param resource $socket A valid socket resource created with socket_create. |
||
17 | * |
||
18 | * @return resource |
||
19 | */ |
||
20 | public function socketAccept($socket) |
||
21 | { |
||
22 | return socket_accept($socket); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Binds a name to a socket |
||
27 | * |
||
28 | * @param resource $socket A valid socket resource created with socket_create. |
||
29 | * @param string $address If the socket is of the AF_INET family, the |
||
30 | * address is an IP in dotted-quad notation |
||
31 | * (e.g. 127.0.0.1). |
||
32 | * @param int $port The port parameter is only used when |
||
33 | * binding an AF_INET socket, and designates |
||
34 | * the port on which to listen for connections. |
||
35 | * |
||
36 | * @return bool |
||
37 | */ |
||
38 | public function socketBind($socket, string $address, int $port = null) : bool |
||
0 ignored issues
–
show
|
|||
39 | { |
||
40 | return call_user_func_array('socket_bind', func_get_args()); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Clears the error on the socket or the last error code |
||
45 | * |
||
46 | * @param resource $socket A valid socket resource created with socket_create. |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public function socketClearError($socket = null) |
||
0 ignored issues
–
show
|
|||
51 | { |
||
52 | call_user_func_array('socket_clear_error', func_get_args()); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Closes a socket resource |
||
57 | * |
||
58 | * @param resource $socket A valid socket resource created with socket_create |
||
59 | * or socket_accept. |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | public function socketClose($socket) |
||
64 | { |
||
65 | socket_close($socket); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Calculate message buffer size |
||
70 | * |
||
71 | * @param int $level |
||
72 | * @param int $type |
||
73 | * |
||
74 | * @return int |
||
75 | */ |
||
76 | public function socketCmsgSpace(int $level, int $type) : int |
||
77 | { |
||
78 | return socket_cmsg_space($level, $type); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Initiates a connection on a socket |
||
83 | * |
||
84 | * @param resource $socket |
||
85 | * @param string $address The address parameter is either an IPv4 address |
||
86 | * in dotted-quad notation (e.g. 127.0.0.1) if |
||
87 | * socket is AF_INET, a valid |
||
88 | * IPv6 address (e.g. ::1) if IPv6 support is enabled and |
||
89 | * socket is AF_INET6 |
||
90 | * or the pathname of a Unix domain socket, if the socket family is |
||
91 | * AF_UNIX. |
||
92 | * @param int $port The port parameter is only used and is mandatory |
||
93 | * when connecting to an AF_INET or an |
||
94 | * AF_INET6 socket, and designates |
||
95 | * the port on the remote host to which a connection should be made. |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | public function socketConnect($socket, string $address, int $port = null) : bool |
||
0 ignored issues
–
show
|
|||
100 | { |
||
101 | return call_user_func_array('socket_connect', func_get_args()); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Opens a socket on port to accept connections |
||
106 | * |
||
107 | * @param int $port The port on which to listen on all interfaces. |
||
108 | * @param int $backlog The backlog parameter defines the maximum length |
||
109 | * the queue of pending connections may grow to. |
||
110 | * SOMAXCONN may be passed as |
||
111 | * backlog parameter, see |
||
112 | * socket_listen for more information. |
||
113 | * |
||
114 | * @return resource |
||
115 | */ |
||
116 | public function socketCreateListen(int $port, int $backlog = null) |
||
0 ignored issues
–
show
|
|||
117 | { |
||
118 | return call_user_func_array('socket_create_listen', func_get_args()); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Creates a pair of indistinguishable sockets and stores them in an array |
||
123 | * |
||
124 | * @param int $domain The domain parameter specifies the protocol |
||
125 | * family to be used by the socket. See socket_create |
||
126 | * for the full list. |
||
127 | * @param int $type The type parameter selects the type of communication |
||
128 | * to be used by the socket. See socket_create for the |
||
129 | * full list. |
||
130 | * @param int $protocol The protocol parameter sets the specific |
||
131 | * protocol within the specified domain to be used |
||
132 | * when communicating on the returned socket. The proper value can be retrieved by |
||
133 | * name by using getprotobyname. If |
||
134 | * the desired protocol is TCP, or UDP the corresponding constants |
||
135 | * SOL_TCP, and SOL_UDP |
||
136 | * can also be used. |
||
137 | * @param array $fd Reference to an array in which the two socket resources will be inserted. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function socketCreatePair(int $domain, int $type, int $protocol, array &$fd) : bool |
||
142 | { |
||
143 | return socket_create_pair($domain, $type, $protocol, $fd); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Create a socket (endpoint for communication) |
||
148 | * |
||
149 | * @param int $domain The domain parameter specifies the protocol |
||
150 | * family to be used by the socket. |
||
151 | * @param int $type The type parameter selects the type of communication |
||
152 | * to be used by the socket. |
||
153 | * @param int $protocol The protocol parameter sets the specific |
||
154 | * protocol within the specified domain to be used |
||
155 | * when communicating on the returned socket. The proper value can be |
||
156 | * retrieved by name by using getprotobyname. If |
||
157 | * the desired protocol is TCP, or UDP the corresponding constants |
||
158 | * SOL_TCP, and SOL_UDP |
||
159 | * can also be used. |
||
160 | * |
||
161 | * @return resource |
||
162 | */ |
||
163 | public function socketCreate(int $domain, int $type, int $protocol) |
||
164 | { |
||
165 | return socket_create($domain, $type, $protocol); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * Gets socket options for the socket |
||
170 | * |
||
171 | * @param resource $socket A valid socket resource created with socket_create |
||
172 | * or socket_accept. |
||
173 | * @param int $level The level parameter specifies the protocol |
||
174 | * level at which the option resides. For example, to retrieve options at |
||
175 | * the socket level, a level parameter of |
||
176 | * SOL_SOCKET would be used. Other levels, such as |
||
177 | * TCP, can be used by |
||
178 | * specifying the protocol number of that level. Protocol numbers can be |
||
179 | * found by using the getprotobyname function. |
||
180 | * @param int $optname |
||
181 | * |
||
182 | * @return mixed |
||
183 | */ |
||
184 | public function socketGetOption($socket, int $level, int $optname) |
||
185 | { |
||
186 | return socket_get_option($socket, $level, $optname); |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * Queries the remote side of the given socket which may either result in host/port or in a Unix filesystem path, |
||
191 | * dependent on its type |
||
192 | * |
||
193 | * @param resource $socket A valid socket resource created with socket_create |
||
194 | * or socket_accept. |
||
195 | * @param string $address If the given socket is of type AF_INET or |
||
196 | * AF_INET6, socket_getpeername |
||
197 | * will return the peers (remote) IP address in |
||
198 | * appropriate notation (e.g. 127.0.0.1 or |
||
199 | * fe80::1) in the address |
||
200 | * parameter and, if the optional port parameter is |
||
201 | * present, also the associated port. |
||
202 | * @param int $port If given, this will hold the port associated to |
||
203 | * address. |
||
204 | * |
||
205 | * @return bool |
||
206 | */ |
||
207 | public function socketGetpeername($socket, string &$address, int &$port = null) : bool |
||
0 ignored issues
–
show
|
|||
208 | { |
||
209 | return call_user_func_array('socket_getpeername', func_get_args()); |
||
210 | } |
||
211 | |||
212 | /** |
||
213 | * Queries the local side of the given socket which may either result in host/port or in a Unix filesystem path, |
||
214 | * dependent on its type |
||
215 | * |
||
216 | * @param resource $socket A valid socket resource created with socket_create |
||
217 | * or socket_accept. |
||
218 | * @param string $addr If the given socket is of type AF_INET |
||
219 | * or AF_INET6, socket_getsockname |
||
220 | * will return the local IP address in appropriate notation (e.g. |
||
221 | * 127.0.0.1 or fe80::1) in the |
||
222 | * address parameter and, if the optional |
||
223 | * port parameter is present, also the associated port. |
||
224 | * @param int $port If provided, this will hold the associated port. |
||
225 | * |
||
226 | * @return bool |
||
227 | */ |
||
228 | public function socketGetsockname($socket, string &$addr, int &$port = null) : bool |
||
0 ignored issues
–
show
|
|||
229 | { |
||
230 | return call_user_func_array('socket_getsockname', func_get_args()); |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Import a stream |
||
235 | * |
||
236 | * @param resource $stream The stream resource to import. |
||
237 | * |
||
238 | * @return resource |
||
239 | */ |
||
240 | public function socketImportStream($stream) |
||
241 | { |
||
242 | return socket_import_stream($stream); |
||
243 | } |
||
244 | |||
245 | /** |
||
246 | * Returns the last error on the socket |
||
247 | * |
||
248 | * @param resource $socket A valid socket resource created with socket_create. |
||
249 | * |
||
250 | * @return int |
||
251 | */ |
||
252 | public function socketLastError($socket = null) : int |
||
0 ignored issues
–
show
|
|||
253 | { |
||
254 | return call_user_func_array('socket_last_error', func_get_args()); |
||
255 | } |
||
256 | |||
257 | /** |
||
258 | * Listens for a connection on a socket |
||
259 | * |
||
260 | * @param resource $socket A valid socket resource created with socket_create. |
||
261 | * @param int $backlog A maximum of backlog incoming connections will be |
||
262 | * queued for processing. If a connection request arrives with the queue |
||
263 | * full the client may receive an error with an indication of |
||
264 | * ECONNREFUSED, or, if the underlying protocol supports |
||
265 | * retransmission, the request may be ignored so that retries may succeed. |
||
266 | * |
||
267 | * @return bool |
||
268 | */ |
||
269 | public function socketListen($socket, int $backlog = null) : bool |
||
0 ignored issues
–
show
|
|||
270 | { |
||
271 | return call_user_func_array('socket_listen', func_get_args()); |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * Reads a maximum of length bytes from a socket |
||
276 | * |
||
277 | * @param resource $socket A valid socket resource created with socket_create |
||
278 | * or socket_accept. |
||
279 | * @param int $length The maximum number of bytes read is specified by the |
||
280 | * length parameter. Otherwise you can use |
||
281 | * r, n, |
||
282 | * or 0 to end reading (depending on the type |
||
283 | * parameter, see below). |
||
284 | * @param int $type Optional type parameter is a named constant: |
||
285 | * |
||
286 | * |
||
287 | * |
||
288 | * PHP_BINARY_READ (Default) - use the system |
||
289 | * recv() function. Safe for reading binary data. |
||
290 | * |
||
291 | * |
||
292 | * |
||
293 | * |
||
294 | * PHP_NORMAL_READ - reading stops at |
||
295 | * \n or \r. |
||
296 | * |
||
297 | * @return string |
||
298 | */ |
||
299 | public function socketRead($socket, int $length, int $type = null) : string |
||
0 ignored issues
–
show
|
|||
300 | { |
||
301 | return call_user_func_array('socket_read', func_get_args()); |
||
302 | } |
||
303 | |||
304 | /** |
||
305 | * Receives data from a connected socket |
||
306 | * |
||
307 | * @param resource $socket The socket must be a socket resource previously |
||
308 | * created by socket_create(). |
||
309 | * @param string $buf The data received will be fetched to the variable specified with |
||
310 | * buf. If an error occurs, if the |
||
311 | * connection is reset, or if no data is |
||
312 | * available, buf will be set to . |
||
313 | * @param int $len Up to len bytes will be fetched from remote host. |
||
314 | * @param int $flags The value of flags can be any combination of |
||
315 | * the following flags, joined with the binary OR (|) |
||
316 | * operator. |
||
317 | * |
||
318 | * @return int |
||
319 | */ |
||
320 | public function socketRecv($socket, string &$buf, int $len, int $flags) : int |
||
321 | { |
||
322 | return socket_recv($socket, $buf, $len, $flags); |
||
323 | } |
||
324 | |||
325 | /** |
||
326 | * Receives data from a socket whether or not it is connection-oriented |
||
327 | * |
||
328 | * @param resource $socket The socket must be a socket resource previously |
||
329 | * created by socket_create(). |
||
330 | * @param string $buf The data received will be fetched to the variable specified with |
||
331 | * buf. |
||
332 | * @param int $len Up to len bytes will be fetched from remote host. |
||
333 | * @param int $flags The value of flags can be any combination of |
||
334 | * the following flags, joined with the binary OR (|) |
||
335 | * operator. |
||
336 | * @param string $name If the socket is of the type AF_UNIX type, |
||
337 | * name is the path to the file. Else, for |
||
338 | * unconnected sockets, name is the IP address of, |
||
339 | * the remote host, or if the socket is connection-oriented. |
||
340 | * @param int $port This argument only applies to AF_INET and |
||
341 | * AF_INET6 sockets, and specifies the remote port |
||
342 | * from which the data is received. If the socket is connection-oriented, |
||
343 | * port will be . |
||
344 | * |
||
345 | * @return int |
||
346 | */ |
||
347 | public function socketRecvfrom($socket, string &$buf, int $len, int $flags, string &$name, int &$port = null) : int |
||
0 ignored issues
–
show
|
|||
348 | { |
||
349 | return call_user_func_array('socket_recvfrom', func_get_args()); |
||
350 | } |
||
351 | |||
352 | /** |
||
353 | * Read a message |
||
354 | * |
||
355 | * @param resource $socket |
||
356 | * @param string $message |
||
357 | * @param int $flags |
||
358 | * |
||
359 | * @return int |
||
360 | */ |
||
361 | public function socketRecvmsg($socket, string $message, int $flags = null) : int |
||
0 ignored issues
–
show
|
|||
362 | { |
||
363 | return call_user_func_array('socket_recvmsg', func_get_args()); |
||
364 | } |
||
365 | |||
366 | /** |
||
367 | * Runs the select() system call on the given arrays of sockets with a specified timeout |
||
368 | * |
||
369 | * @param array $read The sockets listed in the read array will be |
||
370 | * watched to see if characters become available for reading (more |
||
371 | * precisely, to see if a read will not block - in particular, a socket |
||
372 | * resource is also ready on end-of-file, in which case a |
||
373 | * socket_read will return a zero length string). |
||
374 | * @param array $write The sockets listed in the write array will be |
||
375 | * watched to see if a write will not block. |
||
376 | * @param array $except The sockets listed in the except array will be |
||
377 | * watched for exceptions. |
||
378 | * @param int $tvSec The tv_sec and tv_usec |
||
379 | * together form the timeout parameter. The |
||
380 | * timeout is an upper bound on the amount of time |
||
381 | * elapsed before socket_select return. |
||
382 | * tv_sec may be zero , causing |
||
383 | * socket_select to return immediately. This is useful |
||
384 | * for polling. If tv_sec is (no timeout), |
||
385 | * socket_select can block indefinitely. |
||
386 | * @param int $tvUsec |
||
387 | * |
||
388 | * @return int |
||
389 | */ |
||
390 | public function socketSelect(array &$read, array &$write, array &$except, int $tvSec, int $tvUsec = null) : int |
||
0 ignored issues
–
show
|
|||
391 | { |
||
392 | return call_user_func_array('socket_select', func_get_args()); |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * Sends data to a connected socket |
||
397 | * |
||
398 | * @param resource $socket A valid socket resource created with socket_create |
||
399 | * or socket_accept. |
||
400 | * @param string $buf A buffer containing the data that will be sent to the remote host. |
||
401 | * @param int $len The number of bytes that will be sent to the remote host from |
||
402 | * buf. |
||
403 | * @param int $flags The value of flags can be any combination of |
||
404 | * the following flags, joined with the binary OR (|) |
||
405 | * operator. |
||
406 | * |
||
407 | * Possible values for flags |
||
408 | * |
||
409 | * |
||
410 | * |
||
411 | * MSG_OOB |
||
412 | * |
||
413 | * Send OOB (out-of-band) data. |
||
414 | * |
||
415 | * |
||
416 | * |
||
417 | * MSG_EOR |
||
418 | * |
||
419 | * Indicate a record mark. The sent data completes the record. |
||
420 | * |
||
421 | * |
||
422 | * |
||
423 | * MSG_EOF |
||
424 | * |
||
425 | * Close the sender side of the socket and include an appropriate |
||
426 | * notification of this at the end of the sent data. The sent data |
||
427 | * completes the transaction. |
||
428 | * |
||
429 | * |
||
430 | * |
||
431 | * MSG_DONTROUTE |
||
432 | * |
||
433 | * Bypass routing, use direct interface. |
||
434 | * |
||
435 | * @return int |
||
436 | */ |
||
437 | public function socketSend($socket, string $buf, int $len, int $flags) : int |
||
438 | { |
||
439 | return socket_send($socket, $buf, $len, $flags); |
||
440 | } |
||
441 | |||
442 | /** |
||
443 | * Send a message |
||
444 | * |
||
445 | * @param resource $socket |
||
446 | * @param array $message |
||
447 | * @param int $flags |
||
448 | * |
||
449 | * @return int |
||
450 | */ |
||
451 | public function socketSendmsg($socket, array $message, int $flags) : int |
||
452 | { |
||
453 | return socket_sendmsg($socket, $message, $flags); |
||
454 | } |
||
455 | |||
456 | /** |
||
457 | * Sends a message to a socket, whether it is connected or not |
||
458 | * |
||
459 | * @param resource $socket A valid socket resource created using socket_create. |
||
460 | * @param string $buf The sent data will be taken from buffer buf. |
||
461 | * @param int $len len bytes from buf will be |
||
462 | * sent. |
||
463 | * @param int $flags The value of flags can be any combination of |
||
464 | * the following flags, joined with the binary OR (|) |
||
465 | * operator. |
||
466 | * |
||
467 | * Possible values for flags |
||
468 | * |
||
469 | * |
||
470 | * |
||
471 | * MSG_OOB |
||
472 | * |
||
473 | * Send OOB (out-of-band) data. |
||
474 | * |
||
475 | * |
||
476 | * |
||
477 | * MSG_EOR |
||
478 | * |
||
479 | * Indicate a record mark. The sent data completes the record. |
||
480 | * |
||
481 | * |
||
482 | * |
||
483 | * MSG_EOF |
||
484 | * |
||
485 | * Close the sender side of the socket and include an appropriate |
||
486 | * notification of this at the end of the sent data. The sent data |
||
487 | * completes the transaction. |
||
488 | * |
||
489 | * |
||
490 | * |
||
491 | * MSG_DONTROUTE |
||
492 | * |
||
493 | * Bypass routing, use direct interface. |
||
494 | * @param string $addr IP address of the remote host. |
||
495 | * @param int $port port is the remote port number at which the data |
||
496 | * will be sent. |
||
497 | * |
||
498 | * @return int |
||
499 | */ |
||
500 | public function socketSendto($socket, string $buf, int $len, int $flags, string $addr, int $port = null) : int |
||
0 ignored issues
–
show
|
|||
501 | { |
||
502 | return call_user_func_array('socket_sendto', func_get_args()); |
||
503 | } |
||
504 | |||
505 | /** |
||
506 | * Sets blocking mode on a socket resource |
||
507 | * |
||
508 | * @param resource $socket A valid socket resource created with socket_create |
||
509 | * or socket_accept. |
||
510 | * |
||
511 | * @return bool |
||
512 | */ |
||
513 | public function socketSetBlock($socket) : bool |
||
514 | { |
||
515 | return socket_set_block($socket); |
||
516 | } |
||
517 | |||
518 | /** |
||
519 | * Sets nonblocking mode for file descriptor fd |
||
520 | * |
||
521 | * @param resource $socket A valid socket resource created with socket_create |
||
522 | * or socket_accept. |
||
523 | * |
||
524 | * @return bool |
||
525 | */ |
||
526 | public function socketSetNonblock($socket) : bool |
||
527 | { |
||
528 | return socket_set_nonblock($socket); |
||
529 | } |
||
530 | |||
531 | /** |
||
532 | * Sets socket options for the socket |
||
533 | * |
||
534 | * @param resource $socket A valid socket resource created with socket_create |
||
535 | * or socket_accept. |
||
536 | * @param int $level The level parameter specifies the protocol |
||
537 | * level at which the option resides. For example, to retrieve options at |
||
538 | * the socket level, a level parameter of |
||
539 | * SOL_SOCKET would be used. Other levels, such as |
||
540 | * TCP, can be used by specifying the protocol number of that level. |
||
541 | * Protocol numbers can be found by using the |
||
542 | * getprotobyname function. |
||
543 | * @param int $optname The available socket options are the same as those for the |
||
544 | * socket_get_option function. |
||
545 | * @param mixed $optval The option value. |
||
546 | * |
||
547 | * @return bool |
||
548 | */ |
||
549 | public function socketSetOption($socket, int $level, int $optname, $optval) : bool |
||
550 | { |
||
551 | return socket_set_option($socket, $level, $optname, $optval); |
||
552 | } |
||
553 | |||
554 | /** |
||
555 | * Shuts down a socket for receiving, sending, or both |
||
556 | * |
||
557 | * @param resource $socket A valid socket resource created with socket_create. |
||
558 | * @param int $how The value of how can be one of the following: |
||
559 | * |
||
560 | * possible values for how |
||
561 | * |
||
562 | * |
||
563 | * |
||
564 | * 0 |
||
565 | * |
||
566 | * Shutdown socket reading |
||
567 | * |
||
568 | * |
||
569 | * |
||
570 | * 1 |
||
571 | * |
||
572 | * Shutdown socket writing |
||
573 | * |
||
574 | * |
||
575 | * |
||
576 | * 2 |
||
577 | * |
||
578 | * Shutdown socket reading and writing |
||
579 | * |
||
580 | * @return bool |
||
581 | */ |
||
582 | public function socketShutdown($socket, int $how = null) : bool |
||
0 ignored issues
–
show
|
|||
583 | { |
||
584 | return call_user_func_array('socket_shutdown', func_get_args()); |
||
585 | } |
||
586 | |||
587 | /** |
||
588 | * Return a string describing a socket error |
||
589 | * |
||
590 | * @param int $errno A valid socket error number, likely produced by |
||
591 | * socket_last_error. |
||
592 | * |
||
593 | * @return string |
||
594 | */ |
||
595 | public function socketStrerror(int $errno) : string |
||
596 | { |
||
597 | return socket_strerror($errno); |
||
598 | } |
||
599 | |||
600 | /** |
||
601 | * Write to a socket |
||
602 | * |
||
603 | * @param resource $socket |
||
604 | * @param string $buffer The buffer to be written. |
||
605 | * @param int $length The optional parameter length can specify an |
||
606 | * alternate length of bytes written to the socket. If this length is |
||
607 | * greater than the buffer length, it is silently truncated to the length |
||
608 | * of the buffer. |
||
609 | * |
||
610 | * @return int |
||
611 | */ |
||
612 | public function socketWrite($socket, string $buffer, int $length = null) : int |
||
0 ignored issues
–
show
|
|||
613 | { |
||
614 | return call_user_func_array('socket_write', func_get_args()); |
||
615 | } |
||
616 | |||
617 | } |
||
618 | |||
619 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.