diff --git a/NEWS b/NEWS index 722d5a7ce47..e39b10d1a65 100644 --- a/NEWS +++ b/NEWS @@ -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). diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index 57996612d2d..6aaa5780298 100644 --- a/ext/sockets/sockaddr_conv.c +++ b/ext/sockets/sockaddr_conv.c @@ -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;