From 95673e5b51e750c5eee1aecd935cbfc5791d741b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 17 Jun 2021 20:56:54 +0200 Subject: [PATCH] Use assignement + case instead of memcpy() --- src/libsodium/crypto_pwhash/argon2/argon2-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index 90c6d073..2922942d 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -76,7 +76,7 @@ static int allocate_memory(block_region **region, uint32_t m_cost); static int allocate_memory(block_region **region, uint32_t m_cost) { - void * base; + void *base; block *memory; size_t memory_size; @@ -99,12 +99,12 @@ allocate_memory(block_region **region, uint32_t m_cost) -1, 0)) == MAP_FAILED) { base = NULL; /* LCOV_EXCL_LINE */ } /* LCOV_EXCL_LINE */ - memcpy(&memory, &base, sizeof memory); + memory = (block *) base; #elif defined(HAVE_POSIX_MEMALIGN) if ((errno = posix_memalign((void **) &base, 64, memory_size)) != 0) { base = NULL; } - memcpy(&memory, &base, sizeof memory); + memory = (block *) base; #else memory = NULL; if (memory_size + 63 < memory_size) { @@ -113,7 +113,7 @@ allocate_memory(block_region **region, uint32_t m_cost) } else if ((base = malloc(memory_size + 63)) != NULL) { uint8_t *aligned = ((uint8_t *) base) + 63; aligned -= (uintptr_t) aligned & 63; - memcpy(&memory, &aligned, sizeof memory); + memory = (block *) aligned; } #endif if (base == NULL) {