2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

netmgr: Don't crash if socket() returns an error in udpconnect

socket() call can return an error - e.g. EMFILE, so we need to handle
this nicely and not crash.

Additionally wrap the socket() call inside a platform independent helper
function as the Socket data type on Windows is unsigned integer:

> This means, for example, that checking for errors when the socket and
> accept functions return should not be done by comparing the return
> value with –1, or seeing if the value is negative (both common and
> legal approaches in UNIX). Instead, an application should use the
> manifest constant INVALID_SOCKET as defined in the Winsock2.h header
> file.
This commit is contained in:
Ondřej Surý
2020-11-07 20:48:37 +01:00
committed by Evan Hunt
parent b558eca633
commit 8af7f81d6c
3 changed files with 55 additions and 5 deletions

View File

@@ -950,6 +950,12 @@ isc__nm_decstats(isc_nm_t *mgr, isc_statscounter_t counterid);
* Decrement socket-related statistics counters.
*/
isc_result_t
isc__nm_socket(int domain, int type, int protocol, uv_os_sock_t *sockp);
/*%<
* Platform independent socket() version
*/
isc_result_t
isc__nm_socket_freebind(uv_os_sock_t fd, sa_family_t sa_family);
/*%<