/* Provenance: openssl/openssl use_proxy (fixed). * repo: openssl/openssl * commit: 654dc11d23468a74fc8ea4672b702dd3feb7be4b * parent: a79c4ce559c6a3a8fd4109e9f33c1185d5bf2def * commit_url: https://github.com/openssl/openssl/commit/654dc11d23468a74fc8ea4672b702dd3feb7be4b * cve: CVE-2025-9232 * license: Apache-2.0 * function: use_proxy * relpath: crypto/http/http_lib.c */ static int use_proxy(const char *no_proxy, const char *server) { size_t sl; const char *found = NULL; char host[NI_MAXHOST]; if (!ossl_assert(server != NULL)) return 0; sl = strlen(server); if (sl >= 2 && sl < sizeof(host) + 2 && server[0] == '[' && server[sl - 1] == ']') { /* strip leading '[' and trailing ']' from escaped IPv6 address */ sl -= 2; strncpy(host, server + 1, sl); host[sl] = '\0'; server = host; } /* * using environment variable names, both lowercase and uppercase variants, * compatible with other HTTP client implementations like wget, curl and git */ if (no_proxy == NULL) no_proxy = ossl_safe_getenv("no_proxy"); if (no_proxy == NULL) no_proxy = ossl_safe_getenv(OPENSSL_NO_PROXY); if (no_proxy != NULL) found = strstr(no_proxy, server); while (found != NULL && ((found != no_proxy && !ossl_isspace(found[-1]) && found[-1] != ',') || (found[sl] != '\0' && !ossl_isspace(found[sl]) && found[sl] != ','))) found = strstr(found + 1, server); return found == NULL; }