Blame SOURCES/0041-Revert-CRYPTO-Suppress-warning-Wstringop-truncation.patch

ca1eb8
From 61227cf82d01ee42300ad7054bfd683536e15acb Mon Sep 17 00:00:00 2001
ca1eb8
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
ca1eb8
Date: Fri, 27 Jul 2018 11:37:20 +0200
ca1eb8
Subject: [PATCH] Revert "CRYPTO: Suppress warning Wstringop-truncation"
ca1eb8
ca1eb8
This reverts commit 2951a9a84bd85f384213a3e071ffc167907df2d7.
ca1eb8
ca1eb8
The original use stpncpy was correct. Changing it to memcpy
ca1eb8
changed the resulting hash. This resulted in users from
ca1eb8
local domain to not be able to authenticate (offline
ca1eb8
authentication was also probably broken) if their hash was
ca1eb8
created before this change.
ca1eb8
ca1eb8
https://pagure.io/SSSD/sssd/issue/3791
ca1eb8
ca1eb8
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ca1eb8
ca1eb8
DOWNSTREAM:
ca1eb8
Resolves: rhbz#1602781 - Local users failed to login with same password
ca1eb8
after upgrading to RHEL7.6
ca1eb8
---
ca1eb8
 src/util/crypto/libcrypto/crypto_sha512crypt.c | 2 +-
ca1eb8
 src/util/crypto/nss/nss_sha512crypt.c          | 2 +-
ca1eb8
 2 files changed, 2 insertions(+), 2 deletions(-)
ca1eb8
ca1eb8
diff --git a/src/util/crypto/libcrypto/crypto_sha512crypt.c b/src/util/crypto/libcrypto/crypto_sha512crypt.c
ca1eb8
index 5861f34b9325f7552491a07e8b85fe35ca5ae607..b074eee555fafac6e486bfdf9efb9ddf4964a990 100644
ca1eb8
--- a/src/util/crypto/libcrypto/crypto_sha512crypt.c
ca1eb8
+++ b/src/util/crypto/libcrypto/crypto_sha512crypt.c
ca1eb8
@@ -277,7 +277,7 @@ static int sha512_crypt_r(const char *key,
ca1eb8
         goto done;
ca1eb8
     }
ca1eb8
 
ca1eb8
-    cp = memcpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
ca1eb8
+    cp = stpncpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
ca1eb8
     buflen -= SALT_PREF_SIZE;
ca1eb8
 
ca1eb8
     if (rounds_custom) {
ca1eb8
diff --git a/src/util/crypto/nss/nss_sha512crypt.c b/src/util/crypto/nss/nss_sha512crypt.c
ca1eb8
index 709cf51961bb7069ddebf3d636aa29b020756f0a..2f1624e6396c40f539a4e2034ab545cad8f05434 100644
ca1eb8
--- a/src/util/crypto/nss/nss_sha512crypt.c
ca1eb8
+++ b/src/util/crypto/nss/nss_sha512crypt.c
ca1eb8
@@ -267,7 +267,7 @@ static int sha512_crypt_r(const char *key,
ca1eb8
         goto done;
ca1eb8
     }
ca1eb8
 
ca1eb8
-    cp = memcpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
ca1eb8
+    cp = stpncpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
ca1eb8
     buflen -= SALT_PREF_SIZE;
ca1eb8
 
ca1eb8
     if (rounds_custom) {
ca1eb8
-- 
ca1eb8
2.14.4
ca1eb8