Fix some more gcc-9 warnings [-Wstringop-truncation]
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 25 Jun 2018 07:53:46 +0000 (09:53 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 25 Jun 2018 13:30:28 +0000 (15:30 +0200)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6586)

apps/passwd.c
ssl/s3_srvr.c

index 56e10ad3d8f15d00b0950414e3a3b42f7e6b69d6..718f0e0124ddaa542987ff04105bc67015455242 100644 (file)
@@ -306,9 +306,9 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
     out_buf[0] = '$';
     out_buf[1] = 0;
     assert(strlen(magic) <= 4); /* "1" or "apr1" */
-    strncat(out_buf, magic, 4);
-    strncat(out_buf, "$", 1);
-    strncat(out_buf, salt, 8);
+    BUF_strlcat(out_buf, magic, sizeof(out_buf));
+    BUF_strlcat(out_buf, "$", sizeof(out_buf));
+    BUF_strlcat(out_buf, salt, sizeof(out_buf));
     assert(strlen(out_buf) <= 6 + 8); /* "$apr1$..salt.." */
     salt_out = out_buf + 2 + strlen(magic);
     salt_len = strlen(salt_out);
index 96d973cd02bb4644a9a3b23f1131310d7530206f..753b804d5012524a8fbcf8c458c101750fb2d788 100644 (file)
@@ -1959,11 +1959,12 @@ int ssl3_send_server_key_exchange(SSL *s)
 
 #ifndef OPENSSL_NO_PSK
         if (type & SSL_kPSK) {
+            size_t len = strlen(s->ctx->psk_identity_hint);
+
             /* copy PSK identity hint */
-            s2n(strlen(s->ctx->psk_identity_hint), p);
-            strncpy((char *)p, s->ctx->psk_identity_hint,
-                    strlen(s->ctx->psk_identity_hint));
-            p += strlen(s->ctx->psk_identity_hint);
+            s2n(len, p);
+            memcpy(p, s->ctx->psk_identity_hint, len);
+            p += len;
         }
 #endif