summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_srvr.c
diff options
context:
space:
mode:
authortedu <>2014-04-16 01:43:06 +0000
committertedu <>2014-04-16 01:43:06 +0000
commitdfe5dbddd74c9bf529f6d716558f2640be992799 (patch)
treea79e54216332550d2177d485189266b0623b9d43 /src/lib/libssl/d1_srvr.c
parent64d17c0b6df11db607e7fbe2b1bc708147f3c1ab (diff)
downloadopenbsd-dfe5dbddd74c9bf529f6d716558f2640be992799.tar.gz
openbsd-dfe5dbddd74c9bf529f6d716558f2640be992799.tar.bz2
openbsd-dfe5dbddd74c9bf529f6d716558f2640be992799.zip
strncpy(d, s, strlen(s)) is a special kind of stupid. even when it's right,
it looks wrong. replace with auditable code and eliminate many strlen calls to improve efficiency. (wait, did somebody say FASTER?) ok beck
Diffstat (limited to 'src/lib/libssl/d1_srvr.c')
-rw-r--r--src/lib/libssl/d1_srvr.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/libssl/d1_srvr.c b/src/lib/libssl/d1_srvr.c
index 47a0c0e2a2..6040dd96ca 100644
--- a/src/lib/libssl/d1_srvr.c
+++ b/src/lib/libssl/d1_srvr.c
@@ -1018,6 +1018,9 @@ dtls1_send_server_key_exchange(SSL *s)
1018 BN_CTX *bn_ctx = NULL; 1018 BN_CTX *bn_ctx = NULL;
1019 1019
1020#endif 1020#endif
1021#ifndef OPENSSL_NO_PSK
1022 size_t pskhintlen;
1023#endif
1021 EVP_PKEY *pkey; 1024 EVP_PKEY *pkey;
1022 unsigned char *p, *d; 1025 unsigned char *p, *d;
1023 int al, i; 1026 int al, i;
@@ -1226,8 +1229,9 @@ dtls1_send_server_key_exchange(SSL *s)
1226#endif /* !OPENSSL_NO_ECDH */ 1229#endif /* !OPENSSL_NO_ECDH */
1227#ifndef OPENSSL_NO_PSK 1230#ifndef OPENSSL_NO_PSK
1228 if (type & SSL_kPSK) { 1231 if (type & SSL_kPSK) {
1232 pskhintlen = strlen(s->ctx->psk_identity_hint);
1229 /* reserve size for record length and PSK identity hint*/ 1233 /* reserve size for record length and PSK identity hint*/
1230 n += 2 + strlen(s->ctx->psk_identity_hint); 1234 n += 2 + pskhintlen;
1231 } else 1235 } else
1232#endif /* !OPENSSL_NO_PSK */ 1236#endif /* !OPENSSL_NO_PSK */
1233 { 1237 {
@@ -1293,10 +1297,10 @@ dtls1_send_server_key_exchange(SSL *s)
1293#ifndef OPENSSL_NO_PSK 1297#ifndef OPENSSL_NO_PSK
1294 if (type & SSL_kPSK) { 1298 if (type & SSL_kPSK) {
1295 /* copy PSK identity hint */ 1299 /* copy PSK identity hint */
1296 s2n(strlen(s->ctx->psk_identity_hint), p); 1300 s2n(pskhintlen, p);
1297 1301
1298 strncpy((char *)p, s->ctx->psk_identity_hint, strlen(s->ctx->psk_identity_hint)); 1302 memcpy(p, s->ctx->psk_identity_hint, pskhintlen);
1299 p += strlen(s->ctx->psk_identity_hint); 1303 p += pskhintlen;
1300 } 1304 }
1301#endif 1305#endif
1302 1306