]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ntlm: Replace strncpy() with memset()+memcpy()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 11 Apr 2020 17:23:54 +0000 (20:23 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:36:50 +0000 (09:36 +0000)
There was nothing wrong with it, except gcc 9.2 logs a warning about it.

src/lib-ntlm/ntlm-encrypt.c

index dcc6a8f74223b08a3d5646e10f687dc052d9807b..067846969e757ee2ed9e24608748084e0f1471b6 100644 (file)
@@ -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]);