Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/mbstring/gen_rare_cp_bitvec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
return;
}

$bitvec = array_fill(0, (0xFFFF / 32) + 1, 0xFFFFFFFF);
$bitvec = array_fill(0, intdiv(0xFFFF, 32) + 1, 0xFFFFFFFF);

$input = file_get_contents($argv[1]);
foreach (explode("\n", $input) as $line) {
Expand Down
11 changes: 10 additions & 1 deletion ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "ext/standard/url_scanner_ex.h"
#include "ext/standard/info.h"
#include "zend_smart_str.h"
#include "zend_exceptions.h"
#include "ext/standard/url.h"
#include "ext/standard/basic_functions.h"
#include "ext/standard/head.h"
Expand Down Expand Up @@ -1724,8 +1725,16 @@ PHPAPI php_session_status php_get_session_status(void)
static bool php_session_abort(void)
{
if (PS(session_status) == php_session_active) {
if (PS(mod_data) || PS(mod_user_implemented)) {
if ((PS(mod_data) || PS(mod_user_implemented)) && PS(mod)->s_close) {
zend_object *old_exception = EG(exception);
EG(exception) = NULL;

PS(mod)->s_close(&PS(mod_data));
if (!EG(exception)) {
EG(exception) = old_exception;
} else if (old_exception) {
zend_exception_set_previous(EG(exception), old_exception);
}
}
PS(session_status) = php_session_none;
return true;
Expand Down
35 changes: 35 additions & 0 deletions ext/session/tests/sessionhandler_validateid_return_type.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--TEST--
SessionHandler::validateId must return bool
--INI--
session.use_strict_mode=1
--EXTENSIONS--
session
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
class MySession extends SessionHandler {
public function validateId($key) {
return null;
}
}

$handler = new MySession();

try {
session_set_save_handler($handler);
session_start();
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}

session_write_close();

try {
session_start();
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Session id must be a string
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i
--EXPECTF--
*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***
Open:

Warning: SessionHandler::close(): Parent session handler is not open in %s on line %d
SessionHandler::open() expects exactly 2 arguments, 0 given

Warning: Undefined global variable $_SESSION in %s on line %d
Expand Down
7 changes: 2 additions & 5 deletions ext/sockets/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx)
const struct in_addr *addr = (const struct in_addr *)data;
socklen_t size = INET_ADDRSTRLEN;
zend_string *str = zend_string_alloc(size - 1, 0);
memset(ZSTR_VAL(str), '\0', size);

ZVAL_NEW_STR(zv, str);

Expand All @@ -581,7 +580,7 @@ static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx)
return;
}

Z_STRLEN_P(zv) = strlen(Z_STRVAL_P(zv));
Z_STR_P(zv) = zend_string_truncate(Z_STR_P(zv), strlen(Z_STRVAL_P(zv)), 0);
}
static const field_descriptor descriptors_sockaddr_in[] = {
{"family", sizeof("family"), false, offsetof(struct sockaddr_in, sin_family), from_zval_write_sa_family, to_zval_read_sa_family},
Expand Down Expand Up @@ -622,8 +621,6 @@ static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx)
socklen_t size = INET6_ADDRSTRLEN;
zend_string *str = zend_string_alloc(size - 1, 0);

memset(ZSTR_VAL(str), '\0', size);

ZVAL_NEW_STR(zv, str);

if (inet_ntop(AF_INET6, addr, Z_STRVAL_P(zv), size) == NULL) {
Expand All @@ -632,7 +629,7 @@ static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx)
return;
}

Z_STRLEN_P(zv) = strlen(Z_STRVAL_P(zv));
Z_STR_P(zv) = zend_string_truncate(Z_STR_P(zv), strlen(Z_STRVAL_P(zv)), 0);
}
static const field_descriptor descriptors_sockaddr_in6[] = {
{"family", sizeof("family"), false, offsetof(struct sockaddr_in6, sin6_family), from_zval_write_sa_family, to_zval_read_sa_family},
Expand Down
18 changes: 3 additions & 15 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,9 @@ ZEND_GET_MODULE(sockets)
static bool php_open_listen_sock(php_socket *sock, unsigned short port, int backlog) /* {{{ */
{
struct sockaddr_in la = {0};
struct hostent *hp;

#ifndef PHP_WIN32
if ((hp = php_network_gethostbyname("0.0.0.0")) == NULL) {
#else
if ((hp = php_network_gethostbyname("localhost")) == NULL) {
#endif
return false;
}

memcpy((char *) &la.sin_addr, hp->h_addr, hp->h_length);
la.sin_family = hp->h_addrtype;
la.sin_addr.s_addr = htonl(INADDR_ANY);
la.sin_family = AF_INET;
la.sin_port = htons(port);

sock->bsd_socket = socket(PF_INET, SOCK_STREAM, 0);
Expand Down Expand Up @@ -1249,8 +1240,6 @@ PHP_FUNCTION(socket_connect)
RETURN_THROWS();
}

memset(&sin6, 0, sizeof(struct sockaddr_in6));

sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons((unsigned short int)port);

Expand Down Expand Up @@ -1629,7 +1618,6 @@ PHP_FUNCTION(socket_recvfrom)
ZSTR_LEN(recv_buf) = retval;
ZSTR_VAL(recv_buf)[ZSTR_LEN(recv_buf)] = '\0';

memset(addrbuf, 0, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &sin6.sin6_addr, addrbuf, sizeof(addrbuf));

ZEND_TRY_ASSIGN_REF_NEW_STR(arg2, recv_buf);
Expand Down Expand Up @@ -1732,7 +1720,7 @@ PHP_FUNCTION(socket_sendto)
}

s_un.sun_family = AF_UNIX;
snprintf(s_un.sun_path, sizeof(s_un.sun_path), "%s", ZSTR_VAL(addr));
memcpy(s_un.sun_path, ZSTR_VAL(addr), ZSTR_LEN(addr) + 1);

retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags, (struct sockaddr *) &s_un, SUN_LEN(&s_un));
break;
Expand Down
2 changes: 1 addition & 1 deletion ext/sockets/tests/socket_create_listen-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ socket_getsockname($sock, $addr, $port);
var_dump($addr, $port);
?>
--EXPECT--
string(9) "127.0.0.1"
string(7) "0.0.0.0"
int(31338)
--CREDITS--
Till Klampaeckel, till@php.net
Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/tests/proc-idle-timeout.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FPM: Process manager config pm.process_idle_timeout
--SKIPIF--
<?php
include "skipif.inc";
if (!getenv("RUN_RESOURCE_HEAVY_TESTS")) die("skip resource-heavy test");
if (!getenv("FPM_RUN_RESOURCE_HEAVY_TESTS")) die("skip FPM resource-heavy test");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
Expand Down
Loading