From 641038c339e190c16623dd45e601c3d9a355c521 Mon Sep 17 00:00:00 2001
From: yanbzhu <yanbzhu@cisco.com>
Date: Mon, 7 Dec 2015 13:41:23 -0500
Subject: [PATCH 4/6] BUG/MINOR: ssl: Fixed code that crashed under
 optimization

strncpy was causing crashes under gcc 4.8.4 with -O2, so switching to
using memcpy.
---
 src/ssl_sock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 7af607d..58b4f81 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -1808,7 +1808,10 @@ static void ssl_sock_populate_sni_keytypes_hplr(const char *str, struct eb_root
 	if (!node) {
 		/* CN not found in tree */
 		s_kt = malloc(sizeof(struct sni_keytype) + i + 1);
-		strncpy((char *)s_kt->name.key, trash.str, i);
+		/* Using memcpy here instead of strncpy.
+		 * strncpy will cause sig_abrt errors under certain version of gcc with -O2
+		 */
+		memcpy(s_kt->name.key, trash.str, i);
 		s_kt->name.key[i] = 0;
 		s_kt->keytypes = 0;
 		ebst_insert(sni_keytypes, &s_kt->name);
-- 
2.5.3

