mirror of
https://github.com/curl/curl.git
synced 2026-07-10 10:57:18 +03:00
build: always use local inet_pton()/inet_ntop() implementations
Also repurpose existing build-time feature checks into unit test 1961,
to verify.
Prior to this patch these functions were auto-detected with both
autotools and cmake. In case of autotools there was an extra
verification phase ensuring the functions work as expected. This step
required running the function, thus was limited to non-cross-builds. For
cross-builds and CMake it always used the system implementation if
present. On Windows it always used the local implementation, because
availability/use is complicated there.
After this patch all platforms, always use the local implementation,
which is known to be accurate. This makes curl behave more consistently,
and simplifies the build process, a fixes cross-builds and CMake
auto-detection differences.
Also:
- test1960: enable unconditionally.
- checksrc: disallow globally, allowlist in `block_ip.c` example.
- dnsd: verify ntop result for NULL before passing to printf.
Ref: https://github.com/curl/curl/pull/22137#issuecomment-4797440983
Ref: #22137
Ref: 8537a5b0bc #16577
Closes #22170
This commit is contained in:
parent
a62e08c5eb
commit
39dec13ec0
22 changed files with 214 additions and 448 deletions
|
|
@ -150,6 +150,7 @@ static struct ip *ip_list_append(struct ip *list, const char *data)
|
|||
ip->maskbits = 128;
|
||||
#endif
|
||||
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
if(inet_pton(ip->family, ip->str, &ip->netaddr) != 1) {
|
||||
free(ip->str);
|
||||
free(ip);
|
||||
|
|
@ -264,6 +265,7 @@ static curl_socket_t opensocket(void *clientp, curlsocktype purpose,
|
|||
if(ip && filter->type == CONNECTION_FILTER_BLACKLIST) {
|
||||
if(filter->verbose) {
|
||||
char buf[128] = { 0 };
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
inet_ntop(address->family, cinaddr, buf, sizeof(buf));
|
||||
fprintf(stderr, "* Rejecting IP %s due to blacklist entry %s.\n",
|
||||
buf, ip->str);
|
||||
|
|
@ -273,6 +275,7 @@ static curl_socket_t opensocket(void *clientp, curlsocktype purpose,
|
|||
else if(!ip && filter->type == CONNECTION_FILTER_WHITELIST) {
|
||||
if(filter->verbose) {
|
||||
char buf[128] = { 0 };
|
||||
/* !checksrc! disable BANNEDFUNC 1 */
|
||||
inet_ntop(address->family, cinaddr, buf, sizeof(buf));
|
||||
fprintf(stderr,
|
||||
"* Rejecting IP %s due to missing whitelist entry.\n", buf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue