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
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 ext/standard/libavifinfo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ partially parse an AVIF payload and to extract the width, height, bit depth and
channel count without depending on the full libavif library.

`avifinfo.h`, `avifinfo.c`, `LICENSE` and `PATENTS` were copied verbatim from: \
https://aomedia.googlesource.com/libavifinfo/+/96f34d945ac7dac229feddfa94dbae66e202b838 \
https://aomedia.googlesource.com/libavifinfo/+/2b924defa4c2cd227540efe164067a8cc913eeba \
They can easily be kept up-to-date the same way.
Loading