[php-src] master: Merge branch 'PHP-8.5'
Ilia Alshanetsky <[email protected]> Fri, 17 Jul 2026 19:32:00 +0000
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: Ilia Alshanetsky (iliaal)
Date: 2026-07-17T15:27:54-04:00
Commit: https://github.com/php/php-src/commit/e7df6398ccc775e5d8022b200bb59e030a047778
Raw diff: https://github.com/php/php-src/commit/e7df6398ccc775e5d8022b200bb59e030a047778.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
ext/sockets: bound interface name copy in from_zval_write_ifindex()
Changed paths:
M ext/sockets/conversions.c
Diff:
diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c
index 76a08559b809..abf9004f522d 100644
--- a/ext/sockets/conversions.c
+++ b/ext/sockets/conversions.c
@@ -1281,11 +1281,10 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context
#elif defined(SIOCGIFINDEX)
{
struct ifreq ifr;
- if (ZSTR_LEN(str) >= sizeof(ifr.ifr_name)) {
+ if (strlcpy(ifr.ifr_name, ZSTR_VAL(str), sizeof(ifr.ifr_name))
+ >= sizeof(ifr.ifr_name)) {
do_from_zval_err(ctx, "the interface name \"%s\" is too large ", ZSTR_VAL(str));
- }
- memcpy(ifr.ifr_name, ZSTR_VAL(str), ZSTR_LEN(str) + 1);
- if (ioctl(ctx->sock->bsd_socket, SIOCGIFINDEX, &ifr) < 0) {
+ } else if (ioctl(ctx->sock->bsd_socket, SIOCGIFINDEX, &ifr) < 0) {
if (errno == ENODEV) {
do_from_zval_err(ctx, "no interface with name \"%s\" could be "
"found", ZSTR_VAL(str));