Fossil SCM
Check for the presence of BIO_ADDR_hostname_string before using it.
Commit
0ef9501cfa0edd49a00f949b665402d638b7ec5491d8bcd33fe70ff7703d9d9d
Parent
e4ca60cd4920133…
2 files changed
+4
+5
-5
M
auto.def
+4
| --- auto.def | ||
| +++ auto.def | ||
| @@ -375,10 +375,14 @@ | ||
| 375 | 375 | # Silence OpenSSL deprecation warnings on Mac OS X 10.7. |
| 376 | 376 | if {[string match *-darwin* [get-define host]]} { |
| 377 | 377 | if {[cctest -cflags {-Wdeprecated-declarations}]} { |
| 378 | 378 | define-append EXTRA_CFLAGS -Wdeprecated-declarations |
| 379 | 379 | } |
| 380 | + } | |
| 381 | + if {[cc-check-function-in-lib BIO_ADDR_hostname_string ssl]} { | |
| 382 | + define HAVE_BIO_ADDR_HS 1 | |
| 383 | + msg-result "Using BIO_ADDR_hostname_string" | |
| 380 | 384 | } |
| 381 | 385 | } else { |
| 382 | 386 | user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support" |
| 383 | 387 | } |
| 384 | 388 | } else { |
| 385 | 389 |
| --- auto.def | |
| +++ auto.def | |
| @@ -375,10 +375,14 @@ | |
| 375 | # Silence OpenSSL deprecation warnings on Mac OS X 10.7. |
| 376 | if {[string match *-darwin* [get-define host]]} { |
| 377 | if {[cctest -cflags {-Wdeprecated-declarations}]} { |
| 378 | define-append EXTRA_CFLAGS -Wdeprecated-declarations |
| 379 | } |
| 380 | } |
| 381 | } else { |
| 382 | user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support" |
| 383 | } |
| 384 | } else { |
| 385 |
| --- auto.def | |
| +++ auto.def | |
| @@ -375,10 +375,14 @@ | |
| 375 | # Silence OpenSSL deprecation warnings on Mac OS X 10.7. |
| 376 | if {[string match *-darwin* [get-define host]]} { |
| 377 | if {[cctest -cflags {-Wdeprecated-declarations}]} { |
| 378 | define-append EXTRA_CFLAGS -Wdeprecated-declarations |
| 379 | } |
| 380 | } |
| 381 | if {[cc-check-function-in-lib BIO_ADDR_hostname_string ssl]} { |
| 382 | define HAVE_BIO_ADDR_HS 1 |
| 383 | msg-result "Using BIO_ADDR_hostname_string" |
| 384 | } |
| 385 | } else { |
| 386 | user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support" |
| 387 | } |
| 388 | } else { |
| 389 |
+5
-5
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -387,19 +387,19 @@ | ||
| 387 | 387 | /* Set the Global.zIpAddr variable to the server we are talking to. |
| 388 | 388 | ** This is used to populate the ipaddr column of the rcvfrom table, |
| 389 | 389 | ** if any files are received from the server. |
| 390 | 390 | */ |
| 391 | 391 | { |
| 392 | -#if OPENSSL_VERSION_NUMBER < 0x10100000 | |
| 392 | +#ifdef HAVE_BIO_ADDR_HS | |
| 393 | + char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1); | |
| 394 | + g.zIpAddr = mprintf("%s", ip); | |
| 395 | + OPENSSL_free(ip); | |
| 396 | +#else | |
| 393 | 397 | /* IPv4 only code */ |
| 394 | 398 | const unsigned char *ip; |
| 395 | 399 | ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); |
| 396 | 400 | g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); |
| 397 | -#else | |
| 398 | - char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1); | |
| 399 | - g.zIpAddr = mprintf("%s", ip); | |
| 400 | - OPENSSL_free(ip); | |
| 401 | 401 | #endif |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | X509_free(cert); |
| 405 | 405 | return 0; |
| 406 | 406 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -387,19 +387,19 @@ | |
| 387 | /* Set the Global.zIpAddr variable to the server we are talking to. |
| 388 | ** This is used to populate the ipaddr column of the rcvfrom table, |
| 389 | ** if any files are received from the server. |
| 390 | */ |
| 391 | { |
| 392 | #if OPENSSL_VERSION_NUMBER < 0x10100000 |
| 393 | /* IPv4 only code */ |
| 394 | const unsigned char *ip; |
| 395 | ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); |
| 396 | g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); |
| 397 | #else |
| 398 | char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1); |
| 399 | g.zIpAddr = mprintf("%s", ip); |
| 400 | OPENSSL_free(ip); |
| 401 | #endif |
| 402 | } |
| 403 | |
| 404 | X509_free(cert); |
| 405 | return 0; |
| 406 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -387,19 +387,19 @@ | |
| 387 | /* Set the Global.zIpAddr variable to the server we are talking to. |
| 388 | ** This is used to populate the ipaddr column of the rcvfrom table, |
| 389 | ** if any files are received from the server. |
| 390 | */ |
| 391 | { |
| 392 | #ifdef HAVE_BIO_ADDR_HS |
| 393 | char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1); |
| 394 | g.zIpAddr = mprintf("%s", ip); |
| 395 | OPENSSL_free(ip); |
| 396 | #else |
| 397 | /* IPv4 only code */ |
| 398 | const unsigned char *ip; |
| 399 | ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2); |
| 400 | g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); |
| 401 | #endif |
| 402 | } |
| 403 | |
| 404 | X509_free(cert); |
| 405 | return 0; |
| 406 |