[epiphany/mcatanzaro/cppcheck] sync-crypto: avoid unnecessary allocations
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/cppcheck] sync-crypto: avoid unnecessary allocations
- Date: Sun, 17 Nov 2019 17:47:48 +0000 (UTC)
commit 7ae4eb88298fb481e8842be3979fbfebca97bd48
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Nov 17 10:37:04 2019 -0600
sync-crypto: avoid unnecessary allocations
cppcheck noticed these buffers are always constant-sized
lib/sync/ephy-sync-crypto.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/lib/sync/ephy-sync-crypto.c b/lib/sync/ephy-sync-crypto.c
index e5333fbc8..05bf888b2 100644
--- a/lib/sync/ephy-sync-crypto.c
+++ b/lib/sync/ephy-sync-crypto.c
@@ -693,15 +693,15 @@ ephy_sync_crypto_derive_master_keys (const char *bundle_hex,
guint8 **ka,
guint8 **kb)
{
+ gsize len = 32; /* The master sync keys are always 32 bytes. */
guint8 *bundle;
- guint8 *ciphertext;
- guint8 *resp_hmac;
+ guint8 ciphertext[2 * len];
+ guint8 resp_hmac[len];
guint8 *resp_hmac_2;
guint8 *xored;
guint8 *wrap_kb;
char *resp_hmac_2_hex;
gboolean retval = TRUE;
- gsize len = 32; /* The master sync keys are always 32 bytes. */
g_assert (bundle_hex);
g_assert (resp_hmac_key);
@@ -711,8 +711,6 @@ ephy_sync_crypto_derive_master_keys (const char *bundle_hex,
g_assert (kb);
bundle = ephy_sync_utils_decode_hex (bundle_hex);
- ciphertext = g_malloc (2 * len);
- resp_hmac = g_malloc (len);
/* Compute the MAC and compare it to the expected value. */
memcpy (ciphertext, bundle, 2 * len);
@@ -743,8 +741,6 @@ ephy_sync_crypto_derive_master_keys (const char *bundle_hex,
out:
g_free (resp_hmac_2);
g_free (resp_hmac_2_hex);
- g_free (resp_hmac);
- g_free (ciphertext);
g_free (bundle);
return retval;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]