3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 06:02:37 +01:00

crypto: Fix valgrind warning

==40686== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
==40686==    at 0x5147037: sendmsg (in /usr/lib64/libc-2.24.so)
==40686==    by 0x43957C: operate_cipher (cipher.c:354)
==40686==    by 0x439C18: l_cipher_decrypt (cipher.c:415)
==40686==    by 0x40FAB8: arc4_skip (crypto.c:181)

Initialize the skip buffer to 0s.  This isn't strictly necessary, but
hides the above valgrind warning.

The aim of arc4 skip is simply to seed some data into the RC4 cipher so
it makes it harder for the attacker to decrypt.  This 'initialization'
doesn't really care what data is fed.
This commit is contained in:
Denis Kenzior 2017-06-06 13:33:08 -05:00
parent 7e2e965eb7
commit ff319b8234

View File

@ -177,6 +177,9 @@ bool arc4_skip(const uint8_t *key, size_t key_len, size_t skip,
if (!cipher) if (!cipher)
return false; return false;
/* This is not strictly necessary, but keeps valgrind happy */
memset(skip_buf, 0, sizeof(skip_buf));
while (skip > sizeof(skip_buf)) { while (skip > sizeof(skip_buf)) {
size_t to_skip = size_t to_skip =
skip > sizeof(skip_buf) ? sizeof(skip_buf) : skip; skip > sizeof(skip_buf) ? sizeof(skip_buf) : skip;