ref: 3ecc22aa0a4430f61c2403d57370a089536d197a
parent: 9d718345ce03b2fad5d7d28e0bcd1cc69ab2b166
author: Martin Guy <martinwguy@gmail.com>
date: Sat Sep 14 15:37:06 EDT 2024
Fix compilation on AIX 7.3 On AIX, compilation fails saying src/http.c: In function 'op_http_conn_start_tls': src/http.c:1944:5: warning: ISO C forbids nested functions [-Wpedantic] 1944 | int ip_len; | ^~~ In file included from /usr/include/netinet/tcp.h:115, from src/http.c:345: src/http.c:1944:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 1944 | int ip_len; src/http.c:1944:24: error: expected expression before '.' token src/http.c:1949:5: error: 'ip_ff' undeclared (first use in this function); did you mean 'ip_fv'? 1949 | ip_len=0; because `/usr/include/netinet/ip-h` contains #define ip_len ip_ff.ip_flen The obvious solution os to rename the int variable to something else.
--- a/src/http.c
+++ b/src/http.c
@@ -1759,7 +1759,8 @@
char *host;
size_t host_len;
unsigned char *ip;
- int ip_len;
+ /* On AIX 7.3, ip_len is #defined to ip_ff.ip_flen and compilation fails */
+ int iplen;
int check_cn;
int ret;
host=_stream->url.host;
@@ -1775,7 +1776,7 @@
/*Check to see if the host was specified as a simple IP address.*/
addr=op_inet_pton(host);
ip=NULL;
- ip_len=0;
+ iplen=0;
if(addr!=NULL){
switch(addr->ai_family){
case AF_INET:{
@@ -1783,7 +1784,7 @@
s=(struct sockaddr_in *)addr->ai_addr;
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
ip=(unsigned char *)&s->sin_addr;
- ip_len=sizeof(s->sin_addr);
+ iplen=sizeof(s->sin_addr);
/*RFC 6125 says, "In this case, the iPAddress subjectAltName must [sic]
be present in the certificate and must [sic] exactly match the IP in
the URI."
@@ -1795,7 +1796,7 @@
s=(struct sockaddr_in6 *)addr->ai_addr;
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
ip=(unsigned char *)&s->sin6_addr;
- ip_len=sizeof(s->sin6_addr);
+ iplen=sizeof(s->sin6_addr);
check_cn=0;
}break;
}
@@ -1879,8 +1880,8 @@
A match occurs if the reference identity octet string and the value
octet strings are identical."*/
cert_ip=ASN1_STRING_get0_data(name->d.iPAddress);
- if(ip_len==ASN1_STRING_length(name->d.iPAddress)
- &&memcmp(ip,cert_ip,ip_len)==0){
+ if(iplen==ASN1_STRING_length(name->d.iPAddress)
+ &&memcmp(ip,cert_ip,iplen)==0){
ret=1;
break;
}
@@ -1941,12 +1942,12 @@
struct addrinfo *addr;
char *host;
unsigned char *ip;
- int ip_len;
+ int iplen;
param=SSL_get0_param(_ssl_conn);
OP_ASSERT(param!=NULL);
host=_stream->url.host;
ip=NULL;
- ip_len=0;
+ iplen=0;
/*Check to see if the host was specified as a simple IP address.*/
addr=op_inet_pton(host);
if(addr!=NULL){
@@ -1956,7 +1957,7 @@
s=(struct sockaddr_in *)addr->ai_addr;
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
ip=(unsigned char *)&s->sin_addr;
- ip_len=sizeof(s->sin_addr);
+ iplen=sizeof(s->sin_addr);
host=NULL;
}break;
case AF_INET6:{
@@ -1964,7 +1965,7 @@
s=(struct sockaddr_in6 *)addr->ai_addr;
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
ip=(unsigned char *)&s->sin6_addr;
- ip_len=sizeof(s->sin6_addr);
+ iplen=sizeof(s->sin6_addr);
host=NULL;
}break;
}
@@ -1972,7 +1973,7 @@
/*Always set both host and ip to prevent matching against an old one.
One of the two will always be NULL, clearing that parameter.*/
X509_VERIFY_PARAM_set1_host(param,host,0);
- X509_VERIFY_PARAM_set1_ip(param,ip,ip_len);
+ X509_VERIFY_PARAM_set1_ip(param,ip,iplen);
if(addr!=NULL)freeaddrinfo(addr);
}
# endif
--
⑨