1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix undefined behavior in php_set_inet6_addr

Postfix `++` on `NULL` is undefined behavior

Closes GH-8607
This commit is contained in:
Ilija Tovilo
2022-05-22 19:16:52 +02:00
parent c12141c860
commit f0480eb4de
2 changed files with 4 additions and 1 deletions

1
NEWS
View File

@@ -110,6 +110,7 @@ PHP NEWS
- Sockets:
. Fixed Solaris builds. (David Carlier)
. Fix undefined behavior in php_set_inet6_addr. (ilutov)
- SPL:
. Fixed bug GH-8121 (SplFileObject - seek and key with csv file inconsistent).

View File

@@ -60,11 +60,13 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
}
if (scope++) {
if (scope) {
zend_long lval = 0;
double dval = 0;
unsigned scope_id = 0;
scope++;
if (IS_LONG == is_numeric_string(scope, strlen(scope), &lval, &dval, 0)) {
if (lval > 0 && (zend_ulong)lval <= UINT_MAX) {
scope_id = lval;