From: Timo Sirainen Date: Sat, 11 Apr 2020 17:23:54 +0000 (+0300) Subject: lib-ntlm: Replace strncpy() with memset()+memcpy() X-Git-Tag: 2.3.11.2~429 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75719bcd6101492c6892b0b5de6e4e5747ef6faa;p=thirdparty%2Fdovecot%2Fcore.git lib-ntlm: Replace strncpy() with memset()+memcpy() There was nothing wrong with it, except gcc 9.2 logs a warning about it. --- diff --git a/src/lib-ntlm/ntlm-encrypt.c b/src/lib-ntlm/ntlm-encrypt.c index dcc6a8f742..067846969e 100644 --- a/src/lib-ntlm/ntlm-encrypt.c +++ b/src/lib-ntlm/ntlm-encrypt.c @@ -39,7 +39,8 @@ void lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE]) unsigned char buffer[14]; unsigned int i; - strncpy((char *)buffer, passwd, sizeof(buffer)); + i_zero(&buffer); + memcpy(buffer, passwd, I_MIN(sizeof(buffer), strlen(passwd))); for (i = 0; i < sizeof(buffer); i++) buffer[i] = i_toupper(buffer[i]);