Skip to content

Commit 3ecc22a

Browse files
martinwguyTimothy B. Terriberry
authored and
Timothy B. Terriberry
committed
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.
1 parent 9d71834 commit 3ecc22a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/http.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,8 @@ static int op_http_verify_hostname(OpusHTTPStream *_stream,SSL *_ssl_conn){
17591759
char *host;
17601760
size_t host_len;
17611761
unsigned char *ip;
1762-
int ip_len;
1762+
/* On AIX 7.3, ip_len is #defined to ip_ff.ip_flen and compilation fails */
1763+
int iplen;
17631764
int check_cn;
17641765
int ret;
17651766
host=_stream->url.host;
@@ -1775,15 +1776,15 @@ static int op_http_verify_hostname(OpusHTTPStream *_stream,SSL *_ssl_conn){
17751776
/*Check to see if the host was specified as a simple IP address.*/
17761777
addr=op_inet_pton(host);
17771778
ip=NULL;
1778-
ip_len=0;
1779+
iplen=0;
17791780
if(addr!=NULL){
17801781
switch(addr->ai_family){
17811782
case AF_INET:{
17821783
struct sockaddr_in *s;
17831784
s=(struct sockaddr_in *)addr->ai_addr;
17841785
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
17851786
ip=(unsigned char *)&s->sin_addr;
1786-
ip_len=sizeof(s->sin_addr);
1787+
iplen=sizeof(s->sin_addr);
17871788
/*RFC 6125 says, "In this case, the iPAddress subjectAltName must [sic]
17881789
be present in the certificate and must [sic] exactly match the IP in
17891790
the URI."
@@ -1795,7 +1796,7 @@ static int op_http_verify_hostname(OpusHTTPStream *_stream,SSL *_ssl_conn){
17951796
s=(struct sockaddr_in6 *)addr->ai_addr;
17961797
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
17971798
ip=(unsigned char *)&s->sin6_addr;
1798-
ip_len=sizeof(s->sin6_addr);
1799+
iplen=sizeof(s->sin6_addr);
17991800
check_cn=0;
18001801
}break;
18011802
}
@@ -1879,8 +1880,8 @@ static int op_http_verify_hostname(OpusHTTPStream *_stream,SSL *_ssl_conn){
18791880
A match occurs if the reference identity octet string and the value
18801881
octet strings are identical."*/
18811882
cert_ip=ASN1_STRING_get0_data(name->d.iPAddress);
1882-
if(ip_len==ASN1_STRING_length(name->d.iPAddress)
1883-
&&memcmp(ip,cert_ip,ip_len)==0){
1883+
if(iplen==ASN1_STRING_length(name->d.iPAddress)
1884+
&&memcmp(ip,cert_ip,iplen)==0){
18841885
ret=1;
18851886
break;
18861887
}
@@ -1941,12 +1942,12 @@ static int op_http_conn_start_tls(OpusHTTPStream *_stream,OpusHTTPConn *_conn,
19411942
struct addrinfo *addr;
19421943
char *host;
19431944
unsigned char *ip;
1944-
int ip_len;
1945+
int iplen;
19451946
param=SSL_get0_param(_ssl_conn);
19461947
OP_ASSERT(param!=NULL);
19471948
host=_stream->url.host;
19481949
ip=NULL;
1949-
ip_len=0;
1950+
iplen=0;
19501951
/*Check to see if the host was specified as a simple IP address.*/
19511952
addr=op_inet_pton(host);
19521953
if(addr!=NULL){
@@ -1956,23 +1957,23 @@ static int op_http_conn_start_tls(OpusHTTPStream *_stream,OpusHTTPConn *_conn,
19561957
s=(struct sockaddr_in *)addr->ai_addr;
19571958
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
19581959
ip=(unsigned char *)&s->sin_addr;
1959-
ip_len=sizeof(s->sin_addr);
1960+
iplen=sizeof(s->sin_addr);
19601961
host=NULL;
19611962
}break;
19621963
case AF_INET6:{
19631964
struct sockaddr_in6 *s;
19641965
s=(struct sockaddr_in6 *)addr->ai_addr;
19651966
OP_ASSERT(addr->ai_addrlen>=sizeof(*s));
19661967
ip=(unsigned char *)&s->sin6_addr;
1967-
ip_len=sizeof(s->sin6_addr);
1968+
iplen=sizeof(s->sin6_addr);
19681969
host=NULL;
19691970
}break;
19701971
}
19711972
}
19721973
/*Always set both host and ip to prevent matching against an old one.
19731974
One of the two will always be NULL, clearing that parameter.*/
19741975
X509_VERIFY_PARAM_set1_host(param,host,0);
1975-
X509_VERIFY_PARAM_set1_ip(param,ip,ip_len);
1976+
X509_VERIFY_PARAM_set1_ip(param,ip,iplen);
19761977
if(addr!=NULL)freeaddrinfo(addr);
19771978
}
19781979
# endif

0 commit comments

Comments
 (0)