From 178b9be8eccffca66434299bf986494c449b10ee Mon Sep 17 00:00:00 2001 From: Roberto Guimaraes Date: Wed, 8 Mar 2017 09:54:04 -0500 Subject: [PATCH] Prevent undefined behavior in memcpy call. CLA: trivial Reviewed-by: Matt Caswell Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/2750) (cherry picked from commit 6aad9393680ccde591905c8d71da92a241756394) --- ssl/ssl_sess.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index c3369a44ae..f50f514212 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -1006,7 +1006,8 @@ int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, return 0; } s->sid_ctx_length = sid_ctx_len; - memcpy(s->sid_ctx, sid_ctx, sid_ctx_len); + if (s->sid_ctx != sid_ctx) + memcpy(s->sid_ctx, sid_ctx, sid_ctx_len); return 1; } -- 2.25.1