ext/sockets: multicast simplification on ipv4 table retrieval and buffer handling. (#14542)

This commit is contained in:
David CARLIER 2024-06-12 18:33:16 +01:00 committed by GitHub
parent 25360ef249
commit 18cfd94de4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -619,8 +619,8 @@ static int _php_source_op_to_ipv4_op(enum source_op sop)
zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr) zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr)
{ {
MIB_IPADDRTABLE *addr_table; MIB_IPADDRTABLE *addr_table;
ULONG size; ULONG size;
DWORD retval; DWORD retval;
DWORD i; DWORD i;
(void) php_sock; /* not necessary */ (void) php_sock; /* not necessary */
@ -635,8 +635,7 @@ zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struc
retry: retry:
retval = GetIpAddrTable(addr_table, &size, 0); retval = GetIpAddrTable(addr_table, &size, 0);
if (retval == ERROR_INSUFFICIENT_BUFFER) { if (retval == ERROR_INSUFFICIENT_BUFFER) {
efree(addr_table); erealloc(addr_table, size);
addr_table = emalloc(size);
goto retry; goto retry;
} }
if (retval != NO_ERROR) { if (retval != NO_ERROR) {
@ -662,8 +661,8 @@ retry:
zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index) zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index)
{ {
MIB_IPADDRTABLE *addr_table; MIB_IPADDRTABLE *addr_table;
ULONG size; ULONG size;
DWORD retval; DWORD retval;
DWORD i; DWORD i;
(void) php_sock; /* not necessary */ (void) php_sock; /* not necessary */
@ -678,8 +677,7 @@ zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, uns
retry: retry:
retval = GetIpAddrTable(addr_table, &size, 0); retval = GetIpAddrTable(addr_table, &size, 0);
if (retval == ERROR_INSUFFICIENT_BUFFER) { if (retval == ERROR_INSUFFICIENT_BUFFER) {
efree(addr_table); erealloc(addr_table, size);
addr_table = emalloc(size);
goto retry; goto retry;
} }
if (retval != NO_ERROR) { if (retval != NO_ERROR) {