diff options
| author | beck <> | 2014-04-26 18:56:38 +0000 |
|---|---|---|
| committer | beck <> | 2014-04-26 18:56:38 +0000 |
| commit | e7dbd7a1e2ad3e12dafa2919bc8603d60416ea4d (patch) | |
| tree | dff54039de6c4454b05953e2ce78edfc5693e6b5 /src/lib/libcrypto/bio | |
| parent | a1c73b72875dcb25545f111b3779cf0f0ebf9c88 (diff) | |
| download | openbsd-e7dbd7a1e2ad3e12dafa2919bc8603d60416ea4d.tar.gz openbsd-e7dbd7a1e2ad3e12dafa2919bc8603d60416ea4d.tar.bz2 openbsd-e7dbd7a1e2ad3e12dafa2919bc8603d60416ea4d.zip | |
Replace all use of ERR_add_error_data with ERR_asprintf_error_data.
This avoids a lot of ugly gymnastics to do snprintfs before sending the
bag of strings to ERR, and eliminates at least one place in dso_dlfctn.c
where it was being called with the incorrect number of arguments and
using random things off the stack as addresses of strings.
ok krw@, jsing@
Diffstat (limited to 'src/lib/libcrypto/bio')
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_conn.c | 25 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 4 |
3 files changed, 19 insertions, 20 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index 05eb362cc6..ecfaf93b99 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
| @@ -129,7 +129,7 @@ err: | |||
| 129 | if (locked) | 129 | if (locked) |
| 130 | CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); | 130 | CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); |
| 131 | if (err) { | 131 | if (err) { |
| 132 | ERR_add_error_data(2, "host=", str); | 132 | ERR_asprintf_error_data("host=%s", str); |
| 133 | return 0; | 133 | return 0; |
| 134 | } else | 134 | } else |
| 135 | return 1; | 135 | return 1; |
| @@ -171,7 +171,7 @@ BIO_get_port(const char *str, unsigned short *port_ptr) | |||
| 171 | *port_ptr = 70; | 171 | *port_ptr = 70; |
| 172 | else { | 172 | else { |
| 173 | SYSerr(SYS_F_GETSERVBYNAME, errno); | 173 | SYSerr(SYS_F_GETSERVBYNAME, errno); |
| 174 | ERR_add_error_data(3, "service='", str, "'"); | 174 | ERR_asprintf_error_data("service='%s'", str); |
| 175 | return (0); | 175 | return (0); |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| @@ -378,7 +378,7 @@ again: | |||
| 378 | s = socket(server.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL); | 378 | s = socket(server.sa.sa_family, SOCK_STREAM, SOCKET_PROTOCOL); |
| 379 | if (s == -1) { | 379 | if (s == -1) { |
| 380 | SYSerr(SYS_F_SOCKET, errno); | 380 | SYSerr(SYS_F_SOCKET, errno); |
| 381 | ERR_add_error_data(3, "port='", host, "'"); | 381 | ERR_asprintf_error_data("port='%s'", host); |
| 382 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET); | 382 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET); |
| 383 | goto err; | 383 | goto err; |
| 384 | } | 384 | } |
| @@ -422,13 +422,13 @@ again: | |||
| 422 | } | 422 | } |
| 423 | #endif | 423 | #endif |
| 424 | SYSerr(SYS_F_BIND, err_num); | 424 | SYSerr(SYS_F_BIND, err_num); |
| 425 | ERR_add_error_data(3, "port='", host, "'"); | 425 | ERR_asprintf_error_data("port='%s'", host); |
| 426 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_BIND_SOCKET); | 426 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_BIND_SOCKET); |
| 427 | goto err; | 427 | goto err; |
| 428 | } | 428 | } |
| 429 | if (listen(s, MAX_LISTEN) == -1) { | 429 | if (listen(s, MAX_LISTEN) == -1) { |
| 430 | SYSerr(SYS_F_BIND, errno); | 430 | SYSerr(SYS_F_BIND, errno); |
| 431 | ERR_add_error_data(3, "port='", host, "'"); | 431 | ERR_asprintf_error_data("port='%s'", host); |
| 432 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_LISTEN_SOCKET); | 432 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET, BIO_R_UNABLE_TO_LISTEN_SOCKET); |
| 433 | goto err; | 433 | goto err; |
| 434 | } | 434 | } |
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index b64d7d7761..d7a8619b38 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c | |||
| @@ -156,7 +156,8 @@ conn_state(BIO *b, BIO_CONNECT *c) | |||
| 156 | 156 | ||
| 157 | if (c->param_port == NULL) { | 157 | if (c->param_port == NULL) { |
| 158 | BIOerr(BIO_F_CONN_STATE, BIO_R_NO_PORT_SPECIFIED); | 158 | BIOerr(BIO_F_CONN_STATE, BIO_R_NO_PORT_SPECIFIED); |
| 159 | ERR_add_error_data(2, "host=", c->param_hostname); | 159 | ERR_asprintf_error_data("host=%s", |
| 160 | c->param_hostname); | ||
| 160 | goto exit_loop; | 161 | goto exit_loop; |
| 161 | } | 162 | } |
| 162 | c->state = BIO_CONN_S_GET_IP; | 163 | c->state = BIO_CONN_S_GET_IP; |
| @@ -193,8 +194,8 @@ conn_state(BIO *b, BIO_CONNECT *c) | |||
| 193 | ret = socket(AF_INET, SOCK_STREAM, SOCKET_PROTOCOL); | 194 | ret = socket(AF_INET, SOCK_STREAM, SOCKET_PROTOCOL); |
| 194 | if (ret == -1) { | 195 | if (ret == -1) { |
| 195 | SYSerr(SYS_F_SOCKET, errno); | 196 | SYSerr(SYS_F_SOCKET, errno); |
| 196 | ERR_add_error_data(4, "host=", | 197 | ERR_asprintf_error_data("host=%s:%s", |
| 197 | c->param_hostname, ":", c->param_port); | 198 | c->param_hostname, c->param_port); |
| 198 | BIOerr(BIO_F_CONN_STATE, | 199 | BIOerr(BIO_F_CONN_STATE, |
| 199 | BIO_R_UNABLE_TO_CREATE_SOCKET); | 200 | BIO_R_UNABLE_TO_CREATE_SOCKET); |
| 200 | goto exit_loop; | 201 | goto exit_loop; |
| @@ -208,9 +209,8 @@ conn_state(BIO *b, BIO_CONNECT *c) | |||
| 208 | if (!BIO_socket_nbio(b->num, 1)) { | 209 | if (!BIO_socket_nbio(b->num, 1)) { |
| 209 | BIOerr(BIO_F_CONN_STATE, | 210 | BIOerr(BIO_F_CONN_STATE, |
| 210 | BIO_R_ERROR_SETTING_NBIO); | 211 | BIO_R_ERROR_SETTING_NBIO); |
| 211 | ERR_add_error_data(4, "host=", | 212 | ERR_asprintf_error_data("host=%s:%s", |
| 212 | c->param_hostname, ":", | 213 | c->param_hostname, c->param_port); |
| 213 | c->param_port); | ||
| 214 | goto exit_loop; | 214 | goto exit_loop; |
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| @@ -221,8 +221,8 @@ conn_state(BIO *b, BIO_CONNECT *c) | |||
| 221 | i = setsockopt(b->num, SOL_SOCKET, SO_KEEPALIVE,(char *)&i, sizeof(i)); | 221 | i = setsockopt(b->num, SOL_SOCKET, SO_KEEPALIVE,(char *)&i, sizeof(i)); |
| 222 | if (i < 0) { | 222 | if (i < 0) { |
| 223 | SYSerr(SYS_F_SOCKET, errno); | 223 | SYSerr(SYS_F_SOCKET, errno); |
| 224 | ERR_add_error_data(4, "host=", | 224 | ERR_asprintf_error_data("host=%s:%s", |
| 225 | c->param_hostname, ":", c->param_port); | 225 | c->param_hostname, c->param_port); |
| 226 | BIOerr(BIO_F_CONN_STATE, BIO_R_KEEPALIVE); | 226 | BIOerr(BIO_F_CONN_STATE, BIO_R_KEEPALIVE); |
| 227 | goto exit_loop; | 227 | goto exit_loop; |
| 228 | } | 228 | } |
| @@ -242,9 +242,8 @@ conn_state(BIO *b, BIO_CONNECT *c) | |||
| 242 | b->retry_reason = BIO_RR_CONNECT; | 242 | b->retry_reason = BIO_RR_CONNECT; |
| 243 | } else { | 243 | } else { |
| 244 | SYSerr(SYS_F_CONNECT, errno); | 244 | SYSerr(SYS_F_CONNECT, errno); |
| 245 | ERR_add_error_data(4, "host=", | 245 | ERR_asprintf_error_data("host=%s:%s", |
| 246 | c->param_hostname, ":", | 246 | c->param_hostname, c->param_port); |
| 247 | c->param_port); | ||
| 248 | BIOerr(BIO_F_CONN_STATE, | 247 | BIOerr(BIO_F_CONN_STATE, |
| 249 | BIO_R_CONNECT_ERROR); | 248 | BIO_R_CONNECT_ERROR); |
| 250 | } | 249 | } |
| @@ -258,8 +257,8 @@ conn_state(BIO *b, BIO_CONNECT *c) | |||
| 258 | if (i) { | 257 | if (i) { |
| 259 | BIO_clear_retry_flags(b); | 258 | BIO_clear_retry_flags(b); |
| 260 | SYSerr(SYS_F_CONNECT, i); | 259 | SYSerr(SYS_F_CONNECT, i); |
| 261 | ERR_add_error_data(4, "host=", | 260 | ERR_asprintf_error_data("host=%s:%s", |
| 262 | c->param_hostname, ":", c->param_port); | 261 | c->param_hostname, c->param_port); |
| 263 | BIOerr(BIO_F_CONN_STATE, | 262 | BIOerr(BIO_F_CONN_STATE, |
| 264 | BIO_R_NBIO_CONNECT_ERROR); | 263 | BIO_R_NBIO_CONNECT_ERROR); |
| 265 | ret = 0; | 264 | ret = 0; |
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index acc746260e..6d5444f666 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
| @@ -122,7 +122,7 @@ BIO_new_file(const char *filename, const char *mode) | |||
| 122 | 122 | ||
| 123 | if (file == NULL) { | 123 | if (file == NULL) { |
| 124 | SYSerr(SYS_F_FOPEN, errno); | 124 | SYSerr(SYS_F_FOPEN, errno); |
| 125 | ERR_add_error_data(5, "fopen('", filename, "', '", mode, "')"); | 125 | ERR_asprintf_error_data("fopen('%s', '%s')", filename, mode); |
| 126 | if (errno == ENOENT) | 126 | if (errno == ENOENT) |
| 127 | BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE); | 127 | BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE); |
| 128 | else | 128 | else |
| @@ -262,7 +262,7 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 262 | fp = fopen(ptr, p); | 262 | fp = fopen(ptr, p); |
| 263 | if (fp == NULL) { | 263 | if (fp == NULL) { |
| 264 | SYSerr(SYS_F_FOPEN, errno); | 264 | SYSerr(SYS_F_FOPEN, errno); |
| 265 | ERR_add_error_data(5, "fopen('", ptr, "', '", p, "')"); | 265 | ERR_asprintf_error_data("fopen('%s', '%s')", ptr, p); |
| 266 | BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB); | 266 | BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB); |
| 267 | ret = 0; | 267 | ret = 0; |
| 268 | break; | 268 | break; |
