Merge pull request #8627 from tom-cosgrove-arm/ip_len

Avoid use of `ip_len` as it clashes with a macro in AIX system headers
This commit is contained in:
Bence Szépkúti 2023-12-18 02:03:17 +00:00 committed by GitHub
commit a085fa8ccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 15 deletions

View File

@ -143,7 +143,7 @@ int mbedtls_net_bind(mbedtls_net_context *ctx, const char *bind_ip, const char *
* \param client_ctx Will contain the connected client socket * \param client_ctx Will contain the connected client socket
* \param client_ip Will contain the client IP address, can be NULL * \param client_ip Will contain the client IP address, can be NULL
* \param buf_size Size of the client_ip buffer * \param buf_size Size of the client_ip buffer
* \param ip_len Will receive the size of the client IP written, * \param cip_len Will receive the size of the client IP written,
* can be NULL if client_ip is null * can be NULL if client_ip is null
* *
* \return 0 if successful, or * \return 0 if successful, or
@ -156,7 +156,7 @@ int mbedtls_net_bind(mbedtls_net_context *ctx, const char *bind_ip, const char *
*/ */
int mbedtls_net_accept(mbedtls_net_context *bind_ctx, int mbedtls_net_accept(mbedtls_net_context *bind_ctx,
mbedtls_net_context *client_ctx, mbedtls_net_context *client_ctx,
void *client_ip, size_t buf_size, size_t *ip_len); void *client_ip, size_t buf_size, size_t *cip_len);
/** /**
* \brief Check and wait for the context to be ready for read/write * \brief Check and wait for the context to be ready for read/write

View File

@ -316,7 +316,7 @@ static int net_would_block(const mbedtls_net_context *ctx)
*/ */
int mbedtls_net_accept(mbedtls_net_context *bind_ctx, int mbedtls_net_accept(mbedtls_net_context *bind_ctx,
mbedtls_net_context *client_ctx, mbedtls_net_context *client_ctx,
void *client_ip, size_t buf_size, size_t *ip_len) void *client_ip, size_t buf_size, size_t *cip_len)
{ {
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
int type; int type;
@ -399,22 +399,22 @@ int mbedtls_net_accept(mbedtls_net_context *bind_ctx,
if (client_ip != NULL) { if (client_ip != NULL) {
if (client_addr.ss_family == AF_INET) { if (client_addr.ss_family == AF_INET) {
struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr; struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr;
*ip_len = sizeof(addr4->sin_addr.s_addr); *cip_len = sizeof(addr4->sin_addr.s_addr);
if (buf_size < *ip_len) { if (buf_size < *cip_len) {
return MBEDTLS_ERR_NET_BUFFER_TOO_SMALL; return MBEDTLS_ERR_NET_BUFFER_TOO_SMALL;
} }
memcpy(client_ip, &addr4->sin_addr.s_addr, *ip_len); memcpy(client_ip, &addr4->sin_addr.s_addr, *cip_len);
} else { } else {
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr; struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr;
*ip_len = sizeof(addr6->sin6_addr.s6_addr); *cip_len = sizeof(addr6->sin6_addr.s6_addr);
if (buf_size < *ip_len) { if (buf_size < *cip_len) {
return MBEDTLS_ERR_NET_BUFFER_TOO_SMALL; return MBEDTLS_ERR_NET_BUFFER_TOO_SMALL;
} }
memcpy(client_ip, &addr6->sin6_addr.s6_addr, *ip_len); memcpy(client_ip, &addr6->sin6_addr.s6_addr, *cip_len);
} }
} }

View File

@ -261,10 +261,10 @@ usage:
} else if (strcmp(q, "DNS") == 0) { } else if (strcmp(q, "DNS") == 0) {
cur->node.type = MBEDTLS_X509_SAN_DNS_NAME; cur->node.type = MBEDTLS_X509_SAN_DNS_NAME;
} else if (strcmp(q, "IP") == 0) { } else if (strcmp(q, "IP") == 0) {
size_t ip_len = 0; size_t ip_addr_len = 0;
cur->node.type = MBEDTLS_X509_SAN_IP_ADDRESS; cur->node.type = MBEDTLS_X509_SAN_IP_ADDRESS;
ip_len = mbedtls_x509_crt_parse_cn_inet_pton(subtype_value, ip); ip_addr_len = mbedtls_x509_crt_parse_cn_inet_pton(subtype_value, ip);
if (ip_len == 0) { if (ip_addr_len == 0) {
mbedtls_printf("mbedtls_x509_crt_parse_cn_inet_pton failed to parse %s\n", mbedtls_printf("mbedtls_x509_crt_parse_cn_inet_pton failed to parse %s\n",
subtype_value); subtype_value);
goto exit; goto exit;

View File

@ -583,10 +583,10 @@ usage:
} else if (strcmp(q, "DNS") == 0) { } else if (strcmp(q, "DNS") == 0) {
cur->node.type = MBEDTLS_X509_SAN_DNS_NAME; cur->node.type = MBEDTLS_X509_SAN_DNS_NAME;
} else if (strcmp(q, "IP") == 0) { } else if (strcmp(q, "IP") == 0) {
size_t ip_len = 0; size_t ip_addr_len = 0;
cur->node.type = MBEDTLS_X509_SAN_IP_ADDRESS; cur->node.type = MBEDTLS_X509_SAN_IP_ADDRESS;
ip_len = mbedtls_x509_crt_parse_cn_inet_pton(subtype_value, ip); ip_addr_len = mbedtls_x509_crt_parse_cn_inet_pton(subtype_value, ip);
if (ip_len == 0) { if (ip_addr_len == 0) {
mbedtls_printf("mbedtls_x509_crt_parse_cn_inet_pton failed to parse %s\n", mbedtls_printf("mbedtls_x509_crt_parse_cn_inet_pton failed to parse %s\n",
subtype_value); subtype_value);
goto exit; goto exit;