1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

openssl: fix use of uninitialized buffer

Make sure that the error buffer is always initialized and simplify the
use of it to make the logic easier.

Bug: https://github.com/bagder/curl/issues/318
Reported-by: sneis
This commit is contained in:
Daniel Stenberg 2015-06-18 14:20:31 +02:00
parent 0e7d76d6a8
commit 26ddc536b0

View File

@ -2137,10 +2137,9 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
else { else {
/* untreated error */ /* untreated error */
unsigned long errdetail; unsigned long errdetail;
char error_buffer[256]; /* OpenSSL documents that this must be at least char error_buffer[256]=""; /* OpenSSL documents that this must be at
256 bytes long. */ least 256 bytes long. */
CURLcode result; CURLcode result;
const char *cert_problem = NULL;
long lerr; long lerr;
connssl->connecting_state = ssl_connect_2; /* the connection failed, connssl->connecting_state = ssl_connect_2; /* the connection failed,
@ -2172,9 +2171,10 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
X509_verify_cert_error_string(lerr)); X509_verify_cert_error_string(lerr));
} }
else else
cert_problem = "SSL certificate problem, verify that the CA cert is" /* strcpy() is fine here as long as the string fits within
" OK."; error_buffer */
strcpy(error_buffer,
"SSL certificate problem, check your CA cert");
break; break;
default: default:
result = CURLE_SSL_CONNECT_ERROR; result = CURLE_SSL_CONNECT_ERROR;
@ -2195,7 +2195,7 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
} }
/* Could be a CERT problem */ /* Could be a CERT problem */
failf(data, "%s%s", cert_problem ? cert_problem : "", error_buffer); failf(data, "%s", error_buffer);
return result; return result;
} }