Skip to content

Commit f0480eb

Browse files
committed
Fix undefined behavior in php_set_inet6_addr
Postfix `++` on `NULL` is undefined behavior Closes GH-8607
1 parent c12141c commit f0480eb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ PHP NEWS
110110

111111
- Sockets:
112112
. Fixed Solaris builds. (David Carlier)
113+
. Fix undefined behavior in php_set_inet6_addr. (ilutov)
113114

114115
- SPL:
115116
. Fixed bug GH-8121 (SplFileObject - seek and key with csv file inconsistent).

ext/sockets/sockaddr_conv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
6060

6161
}
6262

63-
if (scope++) {
63+
if (scope) {
6464
zend_long lval = 0;
6565
double dval = 0;
6666
unsigned scope_id = 0;
6767

68+
scope++;
69+
6870
if (IS_LONG == is_numeric_string(scope, strlen(scope), &lval, &dval, 0)) {
6971
if (lval > 0 && (zend_ulong)lval <= UINT_MAX) {
7072
scope_id = lval;

0 commit comments

Comments
 (0)